From e17efcc98db1dce8652e5669c8fff35c4e817c22 Mon Sep 17 00:00:00 2001 From: UdeshAthukorala Date: Thu, 5 Nov 2020 01:24:12 +0530 Subject: [PATCH] Add source files --- .idea/.gitignore | 2 + .idea/codeStyles/codeStyleConfig.xml | 5 + .idea/misc.xml | 6 ++ .idea/modules.xml | 9 ++ .idea/vcs.xml | 6 ++ OOP_Project-Lake_Nozama.iml | 11 ++ .../OOP_Project-Lake_Nozama/game/Fish.class | Bin 0 -> 600 bytes .../OOP_Project-Lake_Nozama/game/Game.class | Bin 0 -> 4056 bytes .../game/GameController.class | Bin 0 -> 4735 bytes .../game/GridLocation.class | Bin 0 -> 1854 bytes .../game/InhabitantCharacter.class | Bin 0 -> 1021 bytes .../game/InnocentFish.class | Bin 0 -> 493 bytes .../game/KillerFish.class | Bin 0 -> 1787 bytes .../OOP_Project-Lake_Nozama/game/Lotus.class | Bin 0 -> 731 bytes .../game/NormalWarrior.class | Bin 0 -> 2543 bytes .../game/RubberFish.class | Bin 0 -> 1796 bytes .../game/SuperWarrior.class | Bin 0 -> 3115 bytes .../game/Treasure.class | Bin 0 -> 1103 bytes .../game/Warrior.class | Bin 0 -> 2283 bytes src/game/Fish.java | 11 ++ src/game/Game.java | 61 +++++++++++ src/game/GameController.java | 95 ++++++++++++++++++ src/game/GridLocation.java | 60 +++++++++++ src/game/InhabitantCharacter.java | 25 +++++ src/game/InnocentFish.java | 11 ++ src/game/KillerFish.java | 21 ++++ src/game/Lotus.java | 22 ++++ src/game/NormalWarrior.java | 47 +++++++++ src/game/RubberFish.java | 21 ++++ src/game/SuperWarrior.java | 70 +++++++++++++ src/game/Treasure.java | 30 ++++++ src/game/Warrior.java | 67 ++++++++++++ 32 files changed, 580 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/codeStyles/codeStyleConfig.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 OOP_Project-Lake_Nozama.iml create mode 100644 out/production/OOP_Project-Lake_Nozama/game/Fish.class create mode 100644 out/production/OOP_Project-Lake_Nozama/game/Game.class create mode 100644 out/production/OOP_Project-Lake_Nozama/game/GameController.class create mode 100644 out/production/OOP_Project-Lake_Nozama/game/GridLocation.class create mode 100644 out/production/OOP_Project-Lake_Nozama/game/InhabitantCharacter.class create mode 100644 out/production/OOP_Project-Lake_Nozama/game/InnocentFish.class create mode 100644 out/production/OOP_Project-Lake_Nozama/game/KillerFish.class create mode 100644 out/production/OOP_Project-Lake_Nozama/game/Lotus.class create mode 100644 out/production/OOP_Project-Lake_Nozama/game/NormalWarrior.class create mode 100644 out/production/OOP_Project-Lake_Nozama/game/RubberFish.class create mode 100644 out/production/OOP_Project-Lake_Nozama/game/SuperWarrior.class create mode 100644 out/production/OOP_Project-Lake_Nozama/game/Treasure.class create mode 100644 out/production/OOP_Project-Lake_Nozama/game/Warrior.class create mode 100644 src/game/Fish.java create mode 100644 src/game/Game.java create mode 100644 src/game/GameController.java create mode 100644 src/game/GridLocation.java create mode 100644 src/game/InhabitantCharacter.java create mode 100644 src/game/InnocentFish.java create mode 100644 src/game/KillerFish.java create mode 100644 src/game/Lotus.java create mode 100644 src/game/NormalWarrior.java create mode 100644 src/game/RubberFish.java create mode 100644 src/game/SuperWarrior.java create mode 100644 src/game/Treasure.java create mode 100644 src/game/Warrior.java diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..e7e9d11 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,2 @@ +# Default ignored files +/workspace.xml diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..a55e7a1 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..639900d --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..90ed89c --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/OOP_Project-Lake_Nozama.iml b/OOP_Project-Lake_Nozama.iml new file mode 100644 index 0000000..e7b98ac --- /dev/null +++ b/OOP_Project-Lake_Nozama.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/out/production/OOP_Project-Lake_Nozama/game/Fish.class b/out/production/OOP_Project-Lake_Nozama/game/Fish.class new file mode 100644 index 0000000000000000000000000000000000000000..0571850a5f800c52f189e2cf33dad77a89489a2e GIT binary patch literal 600 zcmZuu%T5A85Uhcf=c>rVCqB^xmqd;pG+szdNQehDMvnt-U<}MA%i`m+ykO$N5AdUm z)nMeHn@mr4O?Or8%;(qp2Y_Q7WRSpG26I@KupyzG#AXs(No*@5PK`CunZio7^`IYh zy{~Pzeienrc2Ank!y5&s5#0L>t0Veys*{@%{BDLjyS(fK6q0<3IQJCNj2Tva#Nco*dT&r(ZH$;#9wY8; zj^Vr#k0Hyr%z3cS;hrYb0+|YAafy1iZ)*Sm literal 0 HcmV?d00001 diff --git a/out/production/OOP_Project-Lake_Nozama/game/Game.class b/out/production/OOP_Project-Lake_Nozama/game/Game.class new file mode 100644 index 0000000000000000000000000000000000000000..e26cc62b2a260b727adb5743f499f3e462f773c6 GIT binary patch literal 4056 zcmaJ^Yj_lA6@F*-GP9G(g@uJKP*@;9LT(Ufpc{%nDl|5b$|C7D);dXsWMH$K&Q74< zt!j~4!TY7fOEoHZX{&{r*rcuXT5Y}8TkECj^Z3JG`nNtPzGrrm-GylTaOQmHyytx9 zobP<++dTiD>1P0J#a|5U#0d>24XE;ci-xxv2;oEouff|Qcst&q<6Z;r#JfcNZVm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AZ&quQv>FSvUZ+}b?C5)c0eWAf A@Bjb+ literal 0 HcmV?d00001 diff --git a/out/production/OOP_Project-Lake_Nozama/game/InnocentFish.class b/out/production/OOP_Project-Lake_Nozama/game/InnocentFish.class new file mode 100644 index 0000000000000000000000000000000000000000..d5f75335b1e54965f44ce241e34761a639c42143 GIT binary patch literal 493 zcmah_!A`x;z1AI5E6Uzfbn8N(xmYM;lAJo)|72hTB4uj$;5*n;71u} z3kM(P_GsP zN*N|?ZC4vb6n=)JY}hU&gwSeVQ$-D=7T=4ewzjd**g&fwwA8mD8Ix@`yPVwt<)3)` z7xqIuryu+Q{wR;n>~2Yr96#*r+&lL^&wZQu`=6J80l0~-jRF>@u!O3OJg%GNT^l#B zY~ww=Z^RF5e29s*KwyA_4I$zXrb}flPSdbFCQiiH;{Qmw>H>Zrf05H}DB3ei4{S zPIhD%xY~Zn%>m1)mxYQX`~q?wSc`D9E2^k>Y9x5!+39)ARWx2XyLAd zd#F43689af;=YA72M^G&@RfsyXgYWk3l`QLY~YcD$N1X9Hx4$j<=|V8x^OQDbfiPM zzpivQXh-=;?Bwvo!Bgy7c;?_cd{6rS)J$M1)|mRe+ONemoH6=V;Oj6j1s0f3OGI`3 zSj~FObd-Kl4}!4m`cgARmX&2T>ZhaXxtPd+58V^9t*&}ibTcKKiLu?7O#nt(B;d5V zs?|%I!zxr#*I~Py*z4G0I(BIE`$4EpKN##TTNEkXi0*psAywJRu4!grWQL9+t@<<$ z4%pB6WV+m7`7vi$bCQ+pvk(PlT<^+IwzLX2;v$w9&j?I1^EQ6Kj{>FPB$P$j3{_MX z%)c*tra~OT9and`i?sAL2YzMD{W*<3hLGbO2XQiD0c+pH@9`$gkAYs?w(ye~pSHll zFbUT`40-Ed0#d-VB1?!9F|F@O>55JsCxc!T&bOkYXg0`at?^Peluf zW9@WCBbpPATSxn9jQO(>`$v1vRZG`KYm!3LrRQzBTGcFc1l~H8-?-QWuKd3puJIi# z@C5|2;1hu&*EvdCl(YQjma3O7{|WI2_Y){_wfP6mz``Wvxm!x?a1Q4w(F3pHb)uNv z1ze1+bGXD^hT6-xk}|X@XJ~cd1tyjT$neV!aHd%uU~+xw`T*9Dvlw$sF;<%~oF%>! zbC(l@lsnIpt0)t{#MrLk4RQH7KmPqdCw&{$2pf{Hg+ZU6jw?3_Hm+BDor^?YB(7yN->s`9Hv+qyhGCo XRM6tz=9z@T9y9)wa*pz6{A&LKylSGA literal 0 HcmV?d00001 diff --git a/out/production/OOP_Project-Lake_Nozama/game/Lotus.class b/out/production/OOP_Project-Lake_Nozama/game/Lotus.class new file mode 100644 index 0000000000000000000000000000000000000000..e187d6d4a9cc43cc73c7de67b9493be48295092c GIT binary patch literal 731 zcmZ`#%TB^j5IwiFAf@sW@Bu3BfQ2kwXxNaLkPuyHh%5^&qR^3-rVzn#1SbNqY2EinJ=e1XM?f@)%+`_c zmFu}dO~5EM8s(ONUiW*fOf+53xtR<*&gkCm42Yzge%Btf?2#+uC8!6F?pVNT_U)ll zZTi7ve91Ob{xgAi-w7VpyM;<+P9Wj-IvgKw)afNPi^TsFns@$W)OD_1IgqK^oj=*n zwuLB8Erb!Vu!9J5t9b;HvZOk&y?*t!^W<~`0S?l_84qRfdKy1cl}9#T1A>YsZH!Ty z`4HbkFA5GbLO9OVFU+Fc^W1&win5e1NBg-~9Ko<={7y=9v! zUzsy1Z_r-oXprJz1;&)1wJ2B$3S_pDL!0FIR&o|O%E<+5Y^BLoYPr>3rb1IZM_MW5 h7FECdgqQmW>~GgvyU{``L#^yTTJj?D0tagK!ykCmVlMyy literal 0 HcmV?d00001 diff --git a/out/production/OOP_Project-Lake_Nozama/game/NormalWarrior.class b/out/production/OOP_Project-Lake_Nozama/game/NormalWarrior.class new file mode 100644 index 0000000000000000000000000000000000000000..a9e5e9b8f747c6436895e9d8b755934851152c75 GIT binary patch literal 2543 zcmaJ@T~iZR7=AWin_X5u5>`b~)S?0^v|3XIwJlUIl@Aq)qOEla2eOjvrkf2)zkAW! z&h*aeMQ1w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llq z^>Mes_;okxlv&89%cPwF5)i*~Rk@A@GGW)}UNYb#ZBJl2DYg;1Ed#0Dz-Kw}i@-$k zW>0k>FEj)7YEgn1AMqOa?UJ&R=hw^Y! z=}yp!@}u}}3_A{X@x;PY2YYzt;CuW)`2UPeAQyYg2w$H!;xSGbe>3oP77aW$1~SF_=}B0*@|qk(R!uxNZ&kX3k;^fu*ElDyMl4%(*zX?leyYB&!ip!ONU@{e24T}0iD(~4 zzvZcDAxSKsZF9hLDzScisD^|;8;F0{c%hoQJUFPdL`8buwyRayLR(<*On<|;30(RA zI9%gjagzT-APfE?P~bjIt4=%1=h*VfrOSUp{K4}GX1LpY0_R|16tg@nCvmudIa{7hfVrwl=NtS7d@7&aY&8m@tGh@sJY2lN{0%hfpA`nHb|jQs-n?#h9kR gJ8`DC%Jl0zj-Z4lpEe0dC^XpdE!tzWKjr%DU#-NYi2wiq literal 0 HcmV?d00001 diff --git a/out/production/OOP_Project-Lake_Nozama/game/SuperWarrior.class b/out/production/OOP_Project-Lake_Nozama/game/SuperWarrior.class new file mode 100644 index 0000000000000000000000000000000000000000..f69ea2ec022200e8045c282d66d635c4f0217f6d GIT binary patch literal 3115 zcmaJ@TW}j!8UEILljM!B*(6HrBv3c?C6OT%kw}RPQR_s-mozd?6m#)f-q;&UyJEF+ z?6zE5(sF4EwA`9xV3@pw$F>j3Ot?H{=uBsLfq~(LM}`?5;29VQ-&x7B9D5>-&Yu52 z|LuJLW%c3z?*9hBr|{z#;y4?{Ib>tlhv$39or+-^=X)TD-9B6pOHRj33{iYe5VKKS z#3ixI$B@D080PSKL4H9jUlej*5(o2Qv2=_Gfdz3^(6Ok)mY|(-TqhWluy=6cs{KN5 zPApj^do))q+x|t%_Z`nq)09i5P~7H9g0#k8mcMlgYNcq~WeM`22tc;2fV!1yPD#QZ zd#!920()`FzLxPkf6;NRz^2ExIVyK;oQlu_$8(#Job{c>4JIRrx%OI+S>|OKPt>>E zMX!`~>1J2it5h7`XVP00W_!!Nz3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vt?pX1puN9TCUdCI1VpN1SJDKGHj&6~sE4)w=~i;ADpg1|n8cW6fpgY&q6&)^KP z7dRh){E$X8;;bVhpnkRv^S`Mq<2j17VH|Jq8Kc4P;RpCWC)a05ckpC_yvcBV;r}xU B&Mp7| literal 0 HcmV?d00001 diff --git a/out/production/OOP_Project-Lake_Nozama/game/Treasure.class b/out/production/OOP_Project-Lake_Nozama/game/Treasure.class new file mode 100644 index 0000000000000000000000000000000000000000..2bef9c1fa076aa9347862a7d5fffe22813c79e36 GIT binary patch literal 1103 zcmZ`%O>f#j5S=yO#(^XaG%2J_`e~dt^wvYFT#zCmq4ZFckK+Pc*ofGYF=_Zuy;N#a zsfYf6{-~;NY=;0PMxI^2oq6-#EPwv~`b|V1=)FlUz2NZDM0myFHHSADvNKc@ zl)r9xp5N2143r?z1TvXL(jT>}gF`_nyVmK*%<;^Z+Trg zJdwWU?-)!513lvGzPwcRwy)%9?5hKGy2d*ZROqYVY_?&-u0aID=d*BOw2+syLphAk zCFW6i>;?LZRy{#$cGUS)`o8x319l+3f`1+sv?^V1>~>XqpiZ^xDqoQK*&F*^b)?zd z%ANN83wb3ivdFP0N2W!24tw<0qIZn#QytlJb_H#4QGFcfVf|BQr2MOBWbg_-dD-hl zD0h8qw-%FCq}znm#z4A#Hdb`mdOS`!3EdCJ&e$X54AQ@|h z1Z=Dz7VveB^90tS^OJ;Axgo=;-caIuSWrYDZ5;C(F5JW)yLiz*T;LizmVps8IDkU3<5bT-3D*uB`{S uw&`ie^=!&@6niwCTTB>y>3hCHcuy7FUlq5vJ;P~Ey_&!y&K*p`pxu9Q_oqVu literal 0 HcmV?d00001 diff --git a/out/production/OOP_Project-Lake_Nozama/game/Warrior.class b/out/production/OOP_Project-Lake_Nozama/game/Warrior.class new file mode 100644 index 0000000000000000000000000000000000000000..332b401f3e404a9c2e7f562f148791a59c0d3a32 GIT binary patch literal 2283 zcmah}+j84f6kYN~iXG+NCTW|}G?d0s+8Ro4;1CEYZC!GKCZuh+Rdy8nq>7Z0$^ zWoaJfXg-!^Nt$J8R-{>#r=R5UDIUq?nq00+^H~lXc$~)*JTG`YM zkL@53eh_NV${Kn^xa?Pi>u|ZLAuq!6?yet1wyVJq;espnd6X653*Xa_3nM#-*2S)L zzpFu?6P}3XHH;OOcImZkPaH8m@deyeQS|jeZFk( zCAfNHZ_AE|Fq;rb6Y?VYHNO#587eW&M5Jp{856I;GVv9@Ht`HxR-_rjxQR2;oR#LBG^a6Y;w~%$ zRTEoqOibXsiR&`_HtrbMHc>;}fH1Lx=dyZj9id@dEz4fru87F?qQ$x$*wx4hsK{}T zJZgAe(rs$9O+@KA$od`yuBZ+>-KCMGB>i-KvgrH4mhe;~WeTdj<^I$5{lVkxYX@QE zunmT)jUaG5^=_7h>&gyieIN2YsaxDvnRQZ8@gTro4=z-6+LvuWNWrDg@r(%hXPe#~@Rt$``4iM;hY zdcQq{Y5j`qOAK)^UUIjIzVHA2TXIV)ZllO@K1OciWOs%gdY1bWiifFkP9;2M>6byu zJjLBBxSHgAKsITf=vKOk{^L9670U}mpHx_rvDeX^bX?Mf))nrwci(C~IL z-jE}GZsJywtw>ZEljU{HA32E&tgFpSZKShFB27M~BzT_QvUIw2j;eK1y-cdp3L!4A z-bVEu7Ka~0yxSei=){^Kmh}p(Qg8bPew548GGfc!3p;+x|w<6x~~}#QM#(A+&VO;X^DY2otJi x>^;6+nO##)BkrnsuK1l!JZ~kr_{s Inhabitants=new ArrayList<>(); //store newly created warrior and fish objects + Warrior[] listOfWarriors=new Warrior[4]; //store newly created warrior objects + gamecontroller=new GameController(); //make a new playground(lake) + System.out.println("-------Let's start the game--------"); + int[][] warriorCoordinates=gamecontroller.placeWarriors(); //get random initial coordinates for warriors + String[] warriorNames={"SuperWarrior1","NormalWarrior1","SuperWarrior2","NormalWarrior2"}; + for(int i=0;i<4;i++){ //create two normalWarriors & two superWarriors + Warrior newWarrior; + if(i%2==0){ + newWarrior=new SuperWarrior(warriorNames[i],warriorCoordinates[i][0],warriorCoordinates[i][1]); + }else{ + newWarrior=new NormalWarrior(warriorNames[i],warriorCoordinates[i][0],warriorCoordinates[i][1]); + } + gamecontroller.addCharacters(newWarrior,newWarrior.getXCoordinate(),newWarrior.getYCoordinate()); //insert the newly created warrior into the grid + listOfWarriors[i]=newWarrior; + Inhabitants.add(newWarrior); + } + int[][][] fishAndlotusCoordinates=gamecontroller.placeFishAndLotus(); + int[][] fishCoordinates=fishAndlotusCoordinates[0]; //get random initial coordinates for fish + String[] fishNames={"KillerFish1","KillerFish2","RubberFish1","RubberFish2","InnocentFish1","InnocentFish2"}; + for(int i=0;i<6;i++){ //create fish objects + Fish newfish; + if(i<2){ + newfish=new KillerFish(fishNames[i],fishCoordinates[i][0],fishCoordinates[i][1]); + }else if(i<4){ + newfish=new RubberFish(fishNames[i],fishCoordinates[i][0],fishCoordinates[i][1]); + }else{ + newfish=new InnocentFish(fishNames[i],fishCoordinates[i][0],fishCoordinates[i][1]); + } + gamecontroller.addCharacters(newfish,newfish.getXCoordinate(),newfish.getYCoordinate()); //insert the newly created fish into the grid + Inhabitants.add(newfish); + } + for(int i=0;i possibleCoordinates=new ArrayList<>(); + for(int i=1;i<11;i++){ + int[] a={0,i};int[] b={i,0}; + possibleCoordinates.add(a);possibleCoordinates.add(b); + } + for(int j=0;j<4;j++){ + int temp=ran.nextInt(possibleCoordinates.size()); + int[] coordinates=possibleCoordinates.get(temp); + possibleCoordinates.remove(temp); + initialCoordinates[j][0]=coordinates[0]; + initialCoordinates[j][1]=coordinates[1]; + } + return initialCoordinates; + } + public int[][][] placeFishAndLotus(){ //randomly create the initial coordinates of the fish and lotus + int[][] initialCoordinates1=new int[6][2]; + int[][] initialCoordinates2=new int[5][2]; + ArrayList possibleCoordinates=new ArrayList<>(); + for(int i=1;i<11;i++){ + for(int j=1;j<11;j++){ + if(i==5 && j==5){continue;} + int[] temp={i,j}; + possibleCoordinates.add(temp); + } + } + for(int j=0;j<6;j++){ + int temp=ran.nextInt(possibleCoordinates.size()); + int[] coordinates=possibleCoordinates.get(temp); + possibleCoordinates.remove(temp); + initialCoordinates1[j][0]=coordinates[0]; + initialCoordinates1[j][1]=coordinates[1]; + } + for(int j=0;j<5;j++){ + int temp=ran.nextInt(possibleCoordinates.size()); + int[] coordinates=possibleCoordinates.get(temp); + possibleCoordinates.remove(temp); + initialCoordinates2[j][0]=coordinates[0]; + initialCoordinates2[j][1]=coordinates[1]; + } + int[][][] temp={initialCoordinates1,initialCoordinates2}; + return temp; + } + public void checkTheNewLocation(Warrior w){ + System.out.println(w.getCharacterName()+" moves to "+"("+w.getXCoordinate()+","+w.getYCoordinate()+")"); //print the new position on console + + GridLocation newGridLocation=getTheLocation(w.getXCoordinate(),w.getYCoordinate()); //get the new grid location of the warrior + if(newGridLocation.checkForTreasure()){ //check whether he is win or not + Game.tChest.anounceTheWinner(w); + double finishingTime=System.currentTimeMillis()-w.getStartTime(); + printWinner(w.getCharacterName(),finishingTime); + // System.out.println("Congratz, "+w.getCharacterName()+" won the game !!!!!!!!!!!! -"+" (Finishing Time - "+finishingtime+" ms)"); + } + newGridLocation.checkForFish(); //check for any kind of fish + if(newGridLocation.checkForLotus()){ + if(!w.checkImmortle()){ + w.setImmortal(true); //if there is a lotus then make player immortle + System.out.println(w.getCharacterName()+" become immortal !!!!!!!!!!!"); + } + } + } + public void printWinner(String name,Double time){ //store the winner&time in a file + System.out.println("Congratz, "+name+" won the game !!! - "); + System.out.println(" (Finishing Time - "+time+" ms)"); + System.out.println(" ---Game Over---"); + } +} \ No newline at end of file diff --git a/src/game/GridLocation.java b/src/game/GridLocation.java new file mode 100644 index 0000000..ebcea91 --- /dev/null +++ b/src/game/GridLocation.java @@ -0,0 +1,60 @@ +package game; + +public class GridLocation { + private Object[] charactersOccupiedTheLocation; //store the inhabitants that occupied this + public GridLocation(){ //of the grid at the moment + charactersOccupiedTheLocation=new Object[4]; + } + public Warrior checkWarrior(){ //check whether there is a warrior in this location + Object obj=charactersOccupiedTheLocation[0]; + if(obj!=null){ + return (Warrior)obj; + } + return null; + } + public void checkForFish(){ //check whether there is ant kind of fish in this location + Object obj=charactersOccupiedTheLocation[1]; + if(obj!=null){ + Thread t=new Thread((Fish)obj); + t.start(); //start the thread of the fish + try { + t.join(); //join warrior's thread to the end of the fish thread + } catch (InterruptedException ex) {} + } + } + public boolean checkForLotus(){ //check whether there is a lotus in this location + Object obj=charactersOccupiedTheLocation[2]; + if(obj!=null){return true;} + return false; + } + public boolean checkForTreasure(){ //check whether there is the treasure in this location + Object obj=charactersOccupiedTheLocation[3]; + if(obj!=null){return true;} + return false; + } + public void initiallyFillTheLocation(Object obj){ //add objects to grid location at the start of game + if(obj instanceof Warrior){ + charactersOccupiedTheLocation[0]=obj; + }else if(obj instanceof Fish){ + charactersOccupiedTheLocation[1]=obj; + }else if(obj instanceof Lotus){ + charactersOccupiedTheLocation[2]=obj; + }else{ + charactersOccupiedTheLocation[3]=obj; + } + } + public synchronized void addTheWarrior(Warrior w){ //add the incoming warrior to the location + Warrior obj=(Warrior)charactersOccupiedTheLocation[0]; + while(obj!=null && w.checkMobility() && obj.checkMobility() && obj.checkIsAlive()){ + try { + wait(1000); //1000 + } catch (InterruptedException ex) {} + obj=(Warrior)charactersOccupiedTheLocation[0]; + } + charactersOccupiedTheLocation[0]=w; + } + public synchronized void removeTheWarrior(){ //remove outgoing warrior from the location + charactersOccupiedTheLocation[0]=null; + notifyAll(); + } +} \ No newline at end of file diff --git a/src/game/InhabitantCharacter.java b/src/game/InhabitantCharacter.java new file mode 100644 index 0000000..008ce02 --- /dev/null +++ b/src/game/InhabitantCharacter.java @@ -0,0 +1,25 @@ +package game; + +public abstract class InhabitantCharacter{ + private String characterName; + private int currentXCoordinate; + private int currentYCoordinate; + public void setCharacterName(String name){ + characterName=name; + } + public String getCharacterName(){ + return characterName; + } + public int getXCoordinate(){ + return currentXCoordinate; + } + public int getYCoordinate(){ + return currentYCoordinate; + } + public void setXCoordinate(int x){ + currentXCoordinate=x; + } + public void setYCoordinate(int y){ + currentYCoordinate=y; + } +} \ No newline at end of file diff --git a/src/game/InnocentFish.java b/src/game/InnocentFish.java new file mode 100644 index 0000000..f70e04d --- /dev/null +++ b/src/game/InnocentFish.java @@ -0,0 +1,11 @@ +package game; + +public class InnocentFish extends Fish{ + public InnocentFish(String name,int x,int y){ + super(name,x,y); + } + @Override + public void run(){} + @Override + public void eat(){} +} \ No newline at end of file diff --git a/src/game/KillerFish.java b/src/game/KillerFish.java new file mode 100644 index 0000000..6136e6a --- /dev/null +++ b/src/game/KillerFish.java @@ -0,0 +1,21 @@ +package game; + +public class KillerFish extends Fish{ + public KillerFish(String name,int x,int y){ + super(name,x,y); + } + @Override + public void run(){ + GridLocation gl=Game.gamecontroller.getTheLocation(this.getXCoordinate(),this.getYCoordinate()); //get its location + Warrior w=gl.checkWarrior(); //get the wrrior there + kill(w); //execute kill method + } + public void kill(Warrior w){ + if(!w.checkImmortle()){ + w.setIsAlive(false); //kill the warrior + System.out.println("KillerFish "+this.getCharacterName()+" kills "+w.getCharacterName()); + } + } + @Override + public void eat(){} +} \ No newline at end of file diff --git a/src/game/Lotus.java b/src/game/Lotus.java new file mode 100644 index 0000000..b345e4e --- /dev/null +++ b/src/game/Lotus.java @@ -0,0 +1,22 @@ +package game; + +public class Lotus{ + private int xCoordinate; + private int yCoordinate; + public Lotus(int x,int y){ + xCoordinate=x; + yCoordinate=y; + } + public int getXCoordinate(){ + return xCoordinate; + } + public int getYCoordinate(){ + return yCoordinate; + } + public void setXCoordinate(int x){ + xCoordinate=x; + } + public void setYCoordinate(int y){ + yCoordinate=y; + } +} \ No newline at end of file diff --git a/src/game/NormalWarrior.java b/src/game/NormalWarrior.java new file mode 100644 index 0000000..42930ac --- /dev/null +++ b/src/game/NormalWarrior.java @@ -0,0 +1,47 @@ +package game; +import java.util.*; + +public class NormalWarrior extends Warrior{ + public NormalWarrior(String name,int x,int y){ + super(name,x,y); + } + @Override + public void sleep(){System.out.println("NormalWarrior "+this.getCharacterName()+" sleeps");} + @Override + public void eat(){System.out.println("NormalWarrior "+this.getCharacterName()+" eats");} + @Override + public void swim(){ + int previousXcoordinate=getXCoordinate(); + int previousYcoordinate=getYCoordinate(); + Random ran=new Random(); + boolean foundNewCoordinate=false; + int[] newCoordinates=new int[2]; + while(!foundNewCoordinate){ //Loop will run until a new appropiate set of coordinates is found + int randomInt=ran.nextInt(2); //choose the ccoordinate that is going to be changed(either x or y) + int[] possibleMoves={-1,1}; + int expectedNewX; + int expectedNewY; + if(randomInt==0){ //change only the x coordinate + int nextChange=possibleMoves[ran.nextInt(2)]; //choose whether warrior is going to his left or right + expectedNewX=getXCoordinate()+nextChange; + expectedNewY=getYCoordinate(); + }else{ //change only the y coordinate + int nextChange=possibleMoves[ran.nextInt(2)]; //choose whether warrior is going up or down + expectedNewY=getYCoordinate()+nextChange; + expectedNewX=getXCoordinate(); + } + if((expectedNewX>=0)&&(expectedNewX<11)&&(expectedNewY>=0)&&(expectedNewY<11)){ + GridLocation expectedLocation=Game.gamecontroller.getTheLocation(expectedNewX,expectedNewY); + if(expectedLocation.checkWarrior()==null){ //check whether the new location is already occupied by an other warrior or not + this.setXCoordinate(expectedNewX); //set the new coordinates if new location is vacant + this.setYCoordinate(expectedNewY); + newCoordinates[0]=expectedNewX; + newCoordinates[1]=expectedNewY; + foundNewCoordinate=true; + } + } + } + Game.gamecontroller.tranferTheWarrior(this, previousXcoordinate, previousYcoordinate, newCoordinates[0], newCoordinates[1]); //transfer warrior from old location to new location + Game.gamecontroller.checkTheNewLocation(this); //check the new location + } +} \ No newline at end of file diff --git a/src/game/RubberFish.java b/src/game/RubberFish.java new file mode 100644 index 0000000..9f00e41 --- /dev/null +++ b/src/game/RubberFish.java @@ -0,0 +1,21 @@ +package game; + +public class RubberFish extends Fish{ + public RubberFish(String name,int x,int y){ + super(name,x,y); + } + @Override + public void run(){ + GridLocation gl=Game.gamecontroller.getTheLocation(this.getXCoordinate(),this.getYCoordinate()); + Warrior w=gl.checkWarrior(); //get the wrrior there + eatFins(w); //execute eatfins method + } + @Override + public void eat(){} + public void eatFins(Warrior w){ + if(w.checkIsAlive()){ + System.out.println("RubberFish "+this.getCharacterName()+" eats "+w.getCharacterName()+"'s fins"); + w.setIsMobile(false); //eat fins + } + } +} \ No newline at end of file diff --git a/src/game/SuperWarrior.java b/src/game/SuperWarrior.java new file mode 100644 index 0000000..fa5f425 --- /dev/null +++ b/src/game/SuperWarrior.java @@ -0,0 +1,70 @@ +package game; +import java.util.Random; + +public class SuperWarrior extends Warrior { + public SuperWarrior(String name,int x,int y){ + super(name,x,y); + } + @Override + public void sleep(){System.out.println("SuperWarrior "+this.getCharacterName()+" sleeps");} + @Override + public void eat(){System.out.println("SuperWarrior "+this.getCharacterName()+" eats");} + @Override + public void swim(){ + int previousXcoordinate=getXCoordinate(); + int previousYcoordinate=getYCoordinate(); + Random ran=new Random(); + int[] newCoordinates=new int[2]; + int expectedNewX=-1; + int expectedNewY=-1; + if(!this.checkImmortle()){ + int[] expectedNewCoordinates=lookForLotus(Game.gamecontroller); //first check whether there are lotus flowers in adjacent locations + if(expectedNewCoordinates!=null){ //if lotus are there then try to move to that location + expectedNewX=expectedNewCoordinates[0]; + expectedNewY=expectedNewCoordinates[1]; + } + } + //if there are no lotus in adjacent locations then swim like a normal warrior + do{ + if((expectedNewX>=0)&&(expectedNewX<11)&&(expectedNewY>=0)&&(expectedNewY<11)){ + GridLocation expectedLocation=Game.gamecontroller.getTheLocation(expectedNewX,expectedNewY); + if(expectedLocation.checkWarrior()==null){ //check whether the new location is already occupied by an other warrior or not + setXCoordinate(expectedNewX); //set the new coordinates if new location is vacant + setYCoordinate(expectedNewY); + newCoordinates[0]=expectedNewX; + newCoordinates[1]=expectedNewY; + break; + } + } + int randomInt=ran.nextInt(2); //choose the ccoordinate that is going to be changed(either x or y) + int[] possibleMoves={-1,1}; + if(randomInt==0){ //change only the x coordinate + int nextChange=possibleMoves[ran.nextInt(2)]; //choose whether warrior is going to his left or right + expectedNewX=this.getXCoordinate()+nextChange; + expectedNewY=this.getYCoordinate(); + }else{ //change only the y coordinate + int nextChange=possibleMoves[ran.nextInt(2)]; //choose whether warrior is going up or down + expectedNewY=this.getYCoordinate()+nextChange; + expectedNewX=this.getXCoordinate(); + } + }while(true); + + Game.gamecontroller.tranferTheWarrior(this, previousXcoordinate, previousYcoordinate, newCoordinates[0], newCoordinates[1]); //transfer warrior from old location to new location + Game.gamecontroller.checkTheNewLocation(this); //check the new location + } + public int[] lookForLotus(GameController gc){ //find are there any lotus flowers in adjacent locations + int currentX=this.getXCoordinate(); + int currentY=this.getYCoordinate(); + int[][] coordinateSet={{currentX-1,currentY},{currentX+1,currentY},{currentX,currentY-1},{currentX,currentY+1}}; + for(int i=0;i<4;i++){ + int[] coordinates=coordinateSet[i]; + if((coordinates[0]>=0)&&(coordinates[0]<11)&&(coordinates[1]>=0)&&(coordinates[1]<11)){ + if(gc.getTheLocation(coordinates[0],coordinates[1]).checkForLotus()){ + this.setImmortal(true); + return coordinates; //if there exist lotus then return that coordinates + } + } + } + return null; + } +} \ No newline at end of file diff --git a/src/game/Treasure.java b/src/game/Treasure.java new file mode 100644 index 0000000..5bdc009 --- /dev/null +++ b/src/game/Treasure.java @@ -0,0 +1,30 @@ +package game; +import java.util.*; + +public class Treasure extends Observable{ + private int xCoordinate; + private int yCoordinate; + public Treasure(int x,int y){ + xCoordinate=x; + yCoordinate=y; + } + public int getXCoordinate(){ + return xCoordinate; + } + public int getYCoordinate(){ + return yCoordinate; + } + public void setXCoordinate(int x){ + xCoordinate=x; + } + public void setYCoordinate(int y){ + yCoordinate=y; + } + public void getNotified(Warrior w){ + this.addObserver(w); + } + public void anounceTheWinner(Warrior w){ //notify other warriors that there is a winner + setChanged(); + notifyObservers(w); + } +} \ No newline at end of file diff --git a/src/game/Warrior.java b/src/game/Warrior.java new file mode 100644 index 0000000..0ec6c6f --- /dev/null +++ b/src/game/Warrior.java @@ -0,0 +1,67 @@ +package game; +import java.util.*; + +public abstract class Warrior extends InhabitantCharacter implements Runnable,Observer{ + private static int noOfWarriors; + private boolean isMobile; + private boolean isImmortal; + private boolean isAlive; + private boolean iswon; + private double startTime; + public Warrior(String name,int x,int y){ + this.setCharacterName(name); + this.setXCoordinate(x); + this.setYCoordinate(y); + isMobile=true; + isImmortal=false; + isAlive=true; + iswon=false; + noOfWarriors++; + } + @Override + public void run(){ + notifyTreasureChest(); //notify treasurechest that he start the game + startTime=System.currentTimeMillis(); + while(isMobile && isAlive){ //swim if he is mobile and alive + swim(); + } + } + @Override + public void update(Observable o, Object arg) { + setIsMobile(false); //mobility will get false when another warrior wins + } + public abstract void swim(); + public abstract void sleep(); + public abstract void eat(); + public double getStartTime(){return startTime;} + public void setIsMobile(boolean value){ + isMobile=value; + } + public void setIsAlive(boolean value){ + isAlive=value; + } + public void setImmortal(boolean value){ + isImmortal=value; + } + public boolean checkMobility(){ + return isMobile; + } + public boolean checkIsAlive(){ + return isAlive; + } + public boolean checkImmortle(){ + return isImmortal; + } + public boolean checkIswon(){ + return iswon; + } + public void looseFins(){ + this.setIsMobile(false); + } + public static int getNoOfWarriors(){ + return noOfWarriors; + } + public void notifyTreasureChest(){ + Game.tChest.getNotified(this); //notify treasurechest that he start the game + } +} \ No newline at end of file