1 packagePJ;2
3 importjava.util.ArrayList;4 importjava.util.Scanner;5
6 importplace.Landindex;7 importcard.CardSystem;8
9 public classPlayer {10 private doubledeposit ;11 private doublecash;12 private intPoint;13 private inthousequantity;14 private intstep;15 private doublehouseValue;16 private int direction =1;17 private int location=(int)(Math.random()*67+1);18 privateString name ;19 private intnamei;20 privateString direct ;21 private int special=0;//=0时正常,=1-6时使用了遥控骰子,=7时处于滞留卡状态,=8时处于乌龟卡状态,=9-16时处于福神保佑状态,=17-24时处于财神保佑状态
22 private int[] cards=new int[17];23 private int[] stocks=new int[10];24 Player(double deposit,double cash,int point,int housequantity,int housevalue,int direction,String name,int namei,intspecial){25 this.deposit=deposit;26 this.cash=cash;27 this.Point=point;28 this.housequantity=housequantity;29 this.houseValue=housevalue;30 this.direction=direction;31 this.name=name;32 this.special=special;33 this.namei=namei;34 for(int i=0;i<=16;i++){35 cards[i]=1;36 }37 }38 publicPlayer() {39 //TODO Auto-generated constructor stub
40 }41 public voidmove(){42 if (deposit + cash > 0){43 if(direction==1){44 direct="顺时针";45 }else{46 direct="逆时针";47 }48 System.out.println("现在是玩家"+name+"的回合,您的前进方向是"+direct+"。");49 if(Date.day==1){50 System.out.println("又到了月初,您的存款已在月末获得了10%的利息");51 this.deposit=deposit*1.1;52 }53 System.out.println("您现在可以进行如下操作:");54 MenuPrint.print1();55 Scanner input = newScanner(System.in);56 int digitalInput =input.nextInt();57 while (true) {58 if (digitalInput >= 0 && digitalInput <= 8)59 break;60 else{61 System.out.print("invalid input, please enter again :");62 digitalInput =input.nextInt();63 }64 }65 while (digitalInput != 6 && digitalInput != 7) {66 switch(digitalInput) {67 case 0:68 MenuPrint.printmap();69 System.out.println("还有什么要看的");70 MenuPrint.print1();71 digitalInput =input.nextInt();72 break;73 case 1:74 MenuPrint.printinitialmap();75 System.out.println("还有什么要看的");76 MenuPrint.print1();77 digitalInput =input.nextInt();78 break;79 case 2:80 System.out.println("名称"+"\t\t\t\t"+"功能"+"\t\t"+"类型"+"\t\t"+"价格"+"\t\t"+"适用范围"+"\t\t"+"剩余数量");81 for(int i=0;i<=16;i++){82 System.out.println(i+":"+CardSystem.cardsystem[i].getName()+"\t\t"+CardSystem.cardsystem[i].getFunction()+"\t\t"+CardSystem.cardsystem[i].getType()+"\t\t"+CardSystem.cardsystem[i].getPoint()+"\t\t"+CardSystem.cardsystem[i].getRange()+"\t\t"+cards[i]);83 }84 System.out.println("请选择");85 Scanner in=newScanner(System.in);86 int inner=in.nextInt();87 if(cards[inner]==0){88 System.out.println("此卡数量不足");89 }else{90 CardSystem.cardsystem[inner].print(location, namei);91 cards[inner]--;92 }93 System.out.println("还有什么要看的");94 MenuPrint.print1();95 digitalInput =input.nextInt();96 break;97 case 3:98 boolean luzhang=false;99 for (int i = 1; i <= 10; i++) {100 if (Landindex.mark[location+i].state == false) {101 System.out.println("前方第" + i + "步处有路障,小心哦,还有什么要看的");102 luzhang=true;103 }104 }105 if(!luzhang){106 System.out.println("没有情况;还有什么要看的");107 }108 MenuPrint.print1();109 digitalInput =input.nextInt();110 break;111 case 4:112 System.out.print("请输入您想查询的地方与您相差的步数:");113 String Input =input.next();114 if (Input.equals("q")) {115 System.out.println("还有其它想看的么,请输入 :");116 MenuPrint.print1();117 digitalInput =input.nextInt();118 break;119 } else{120 int i =Integer.parseInt(Input);121 Landindex.mark[(location+i)%68].printInformation((location+i)%68);122 System.out.println("还有其它想的么,请输入 :");123 MenuPrint.print1();124 digitalInput =input.nextInt();125 break;126 }127 case 5:128 System.out.println("玩家"+"\t"+"现金 "+"\t"+"存款 "+"\t"+"房产数"+"\t"+"房产价值"+"\t"+"点券数");129 for(int i=0;i=allprice){160 if(deposit>=allprice){161 deposit-=allprice;162 }else{163 cash-=(allprice-deposit);164 deposit=0;165 }166 stocks[num-1]+=amount;167 Stock.stocksystem[num-1].setHold(Stock.stocksystem[num-1].getHold()+amount);168 System.out.println("购买成功!");169 break;170 }else{171 System.out.println("购买失败,您的金钱不足");172 break;173 }174 }else if(choose.equals("s")){175 //System.out.println("您当前持有量为"+stocks[num-1]+"您要卖出"+amount);
176 if(stocks[num-1]>=amount){177 double allprice=Stock.stocksystem[num-1].getPrice()*amount;178 stocks[num-1]-=amount;179 deposit+=allprice;180 Stock.stocksystem[num-1].setHold(Stock.stocksystem[num-1].getHold()-amount);181 System.out.println("抛售成功!");182 break;183 }else{184 System.out.println("抛售失败,您的持有量不足");185 break;186 }187 }else{188 System.out.print("invalid input, please enter again :");189 stockin=input.next();190 }191 }192 System.out.println("还有其它想的么,请输入 :");193 MenuPrint.print1();194 digitalInput =input.nextInt();195 break;196 }197 }198 }199 if (digitalInput == 6) {200 int actualStep = (int)(Math.random()*6+1);201 //System.out.println("前面"+actualStep);202 //当使用滞留卡时
203 if(special==7){204 actualStep=0;205 special=0;206 //使用遥控骰子时
207 }else if(special>0&&special<=6){208 actualStep=special;209 special=0;210 }211 //遇到路障时
212 for(int i= 1; i < actualStep; i++){213 if (Landindex.mark[(location+i* direction)%68].state == false) {214 System.out.println("前面第" + i + "步遇到了路障,过不去了");215 actualStep =i;216 Landindex.mark[(location+i* direction)%68].state=true;217 location=(location+i* direction)%68;218 break;219 }220 }221 //当经过银行时
222 for (int j = 1; j < actualStep; j++) {223 if (Landindex.mark[(location+j* direction)%68] instanceofplace.Bank) {224 Landindex.mark[(location+j* direction)%68].printaction((location+j* direction)%68, namei);225 break;226 }227 }228 location=(location+actualStep*direction)%68;229 //System.out.println("后面"+actualStep);
230 Landindex.mark[location].printaction(location, namei);231 }232 if (digitalInput == 7) {233 System.out.println("祝您下次游戏愉快~~");234 for(int i=0;i