• R/O
  • SSH
  • HTTPS

Commit

Frequently used words (click to add to your profile)

javaandroidc++linuxc#objective-ccocoa誰得qtrubypythongamewindowsbathyscaphephpguic翻訳omegattwitterframeworktestbtronarduinovb.net計画中(planning stage)directxpreviewerゲームエンジンdom

無人機動兵器ダンジョン探索ゲーム JAVAベース


Commit MetaInfo

Revisão50 (tree)
Hora2016-01-17 00:17:32
Autormanjihq

Mensagem de Log

Java7 ベースに変更

Mudança Sumário

Diff

--- CarnageHack2/trunk/src/CarnageHack/OkeSoftArrowEditPane.java (revision 49)
+++ CarnageHack2/trunk/src/CarnageHack/OkeSoftArrowEditPane.java (revision 50)
@@ -72,6 +72,7 @@
7272 add(button);
7373 }
7474
75+ @Override
7576 public void action(String s) {
7677 int n;
7778
--- CarnageHack2/trunk/src/CarnageHack/OkeSoftRangeEditPane.java (revision 49)
+++ CarnageHack2/trunk/src/CarnageHack/OkeSoftRangeEditPane.java (revision 50)
@@ -77,6 +77,7 @@
7777 add(text);
7878 }
7979
80+ @Override
8081 public void update_component() {
8182 TextField text = (TextField) getComponent(1);
8283 try {
@@ -98,15 +99,18 @@
9899 }
99100 }
100101
102+ @Override
101103 public void actionPerformed(ActionEvent e) {
102104 update_component();
103105 }
104106
107+ @Override
105108 public void focusGained(FocusEvent e) {
106109 TextField text = (TextField) e.getComponent();
107110 text.selectAll();
108111 }
109112
113+ @Override
110114 public void focusLost(FocusEvent e) {
111115 }
112116
--- CarnageHack2/trunk/src/CarnageHack/OkeHardEngine.java (revision 49)
+++ CarnageHack2/trunk/src/CarnageHack/OkeHardEngine.java (revision 50)
@@ -35,6 +35,7 @@
3535 weight = w;
3636 }
3737
38+ @Override
3839 public String get_category() {
3940 return "ENGINE";
4041 }
@@ -57,6 +58,7 @@
5758 return fuelpersec;
5859 }
5960
61+ @Override
6062 public void load(String s) {
6163 String field[] = CHutil.split(s, ',');
6264 name = field[0];
@@ -65,6 +67,7 @@
6567 weight = Integer.parseInt(field[3]);
6668 }
6769
70+ @Override
6871 public String save() {
6972 String s;
7073 s = name + "," + max_weight + "," + fuelpersec + "," + weight;
--- CarnageHack2/trunk/src/CarnageHack/OkeSoftData.java (revision 49)
+++ CarnageHack2/trunk/src/CarnageHack/OkeSoftData.java (revision 50)
@@ -187,10 +187,10 @@
187187 public void save(String fname) {
188188 boolean success;
189189 try {
190- PrintWriter w
191- = new PrintWriter(new BufferedWriter(new FileWriter(fname)));
192- success = save(w);
193- w.close();
190+ try (PrintWriter w = new PrintWriter(new BufferedWriter(
191+ new FileWriter(fname)))) {
192+ success = save(w);
193+ }
194194 } catch (Exception e) {
195195 success = false;
196196 }
@@ -251,10 +251,8 @@
251251 } else {
252252 return false;
253253 }
254- } catch (IOException e) {
254+ } catch (IOException | NumberFormatException e) {
255255 return false;
256- } catch (NumberFormatException e) {
257- return false;
258256 }
259257 }
260258
@@ -267,9 +265,9 @@
267265 public boolean load(String fname) {
268266 boolean success;
269267 try {
270- BufferedReader r = new BufferedReader(new FileReader(fname));
271- success = load(r);
272- r.close();
268+ try (BufferedReader r = new BufferedReader(new FileReader(fname))) {
269+ success = load(r);
270+ }
273271 } catch (Exception e) {
274272 success = false;
275273 }
--- CarnageHack2/trunk/src/CarnageHack/OkeHardOption.java (revision 49)
+++ CarnageHack2/trunk/src/CarnageHack/OkeHardOption.java (revision 50)
@@ -40,6 +40,7 @@
4040 weight = w;
4141 }
4242
43+ @Override
4344 public String get_category() {
4445 return "OPTION";
4546 }
@@ -62,6 +63,7 @@
6263 return effect;
6364 }
6465
66+ @Override
6567 public void load(String s) {
6668 String field[] = CHutil.split(s, ',');
6769 if (field[1].equals("C") == true) {
@@ -80,6 +82,7 @@
8082 weight = Integer.parseInt(field[3]);
8183 }
8284
85+ @Override
8386 public String save() {
8487 String s;
8588 s = name + ",";
--- CarnageHack2/trunk/src/CarnageHack/Oke.java (revision 49)
+++ CarnageHack2/trunk/src/CarnageHack/Oke.java (revision 50)
@@ -256,7 +256,7 @@
256256 recalc_speed();
257257 backpack = new CHArrayList();
258258 fuel = hardware.get_fueltank().get_fuel();
259- traceList = new ArrayList<ChipTrace>();
259+ traceList = new ArrayList<>();
260260 }
261261
262262 /**
@@ -295,12 +295,9 @@
295295 wk = r.readLine();
296296 backpack.add(wk);
297297 }
298- } catch (IOException e) {
298+ } catch (IOException | NumberFormatException e) {
299299 System.out.println("fail load OKE");
300300 System.out.println(e.toString());
301- } catch (NumberFormatException e) {
302- System.out.println("fail load OKE");
303- System.out.println(e.toString());
304301 }
305302 dead = false;
306303 dead_timer = 0;
@@ -313,7 +310,7 @@
313310 speed_count = 0;
314311 tempture = 0;
315312 recalc_speed();
316- traceList = new ArrayList<ChipTrace>();
313+ traceList = new ArrayList<>();
317314 }
318315
319316 /**
--- CarnageHack2/trunk/src/CarnageHack/OkeSoftChip.java (revision 49)
+++ CarnageHack2/trunk/src/CarnageHack/OkeSoftChip.java (revision 50)
@@ -484,7 +484,7 @@
484484 green_arrow = ARROW_NONE;
485485 red_arrow = ARROW_NONE;
486486 }
487- } catch (IOException e) {
487+ } catch (IOException | NumberFormatException e) {
488488 chipid = "";
489489 param = "";
490490 code = null;
@@ -491,13 +491,6 @@
491491 green_arrow = ARROW_NONE;
492492 red_arrow = ARROW_NONE;
493493 bcondchip = false;
494- } catch (NumberFormatException e) {
495- chipid = "";
496- param = "";
497- code = null;
498- green_arrow = ARROW_NONE;
499- red_arrow = ARROW_NONE;
500- bcondchip = false;
501494 }
502495 }
503496 }
@@ -524,10 +517,12 @@
524517 */
525518 class OkeSoftNop implements OkeSoftExec {
526519
520+ @Override
527521 public boolean exec(OkeDungeon dungeon, Oke oke, String param) {
528522 return false;
529523 }
530524
525+ @Override
531526 public boolean edit(OkeSoftChip c, int x, int y, OkeSoftData d,
532527 String param) {
533528 Dialog dialog = new Dialog(CarnageHack.getFrame(),
@@ -582,6 +577,7 @@
582577 OkeSoftMove() {
583578 }
584579
580+ @Override
585581 public boolean exec(OkeDungeon dungeon, Oke oke, String param) {
586582 int move = Integer.parseInt(param);
587583 if (move == STOP) {
@@ -592,6 +588,7 @@
592588 return false;
593589 }
594590
591+ @Override
595592 public boolean edit(OkeSoftChip c, int x, int y,
596593 OkeSoftData d, String param) {
597594 String title;
@@ -665,6 +662,7 @@
665662 OkeSoftTurn() {
666663 }
667664
665+ @Override
668666 public boolean exec(OkeDungeon dungeon, Oke oke, String param) {
669667 if (Integer.parseInt(param) == LEFT) {
670668 oke.set_action(Oke.ACTION_TURN, LEFT);
@@ -674,6 +672,7 @@
674672 return false;
675673 }
676674
675+ @Override
677676 public boolean edit(OkeSoftChip c, int x, int y,
678677 OkeSoftData d, String param) {
679678 String title;
@@ -740,6 +739,7 @@
740739 OkeSoftJump() {
741740 }
742741
742+ @Override
743743 public boolean exec(OkeDungeon dungeon, Oke oke, String param) {
744744 int move = Integer.parseInt(param);
745745 oke.set_action(Oke.ACTION_JUMP, move);
@@ -746,6 +746,7 @@
746746 return false;
747747 }
748748
749+ @Override
749750 public boolean edit(OkeSoftChip c, int x, int y,
750751 OkeSoftData d, String param) {
751752 String title;
@@ -814,6 +815,7 @@
814815 OkeSoftSearchEnemy() {
815816 }
816817
818+ @Override
817819 public boolean exec(OkeDungeon dungeon, Oke oke, String param) {
818820 String field[] = CHutil.split(param, ',');
819821 int direction = Integer.parseInt(field[0]);
@@ -824,6 +826,7 @@
824826 return (target != null);
825827 }
826828
829+ @Override
827830 public boolean edit(OkeSoftChip c, int x, int y,
828831 OkeSoftData d, String param) {
829832 String field[] = CHutil.split(param, ',');
@@ -923,6 +926,7 @@
923926 OkeSoftSearchWall() {
924927 }
925928
929+ @Override
926930 public boolean exec(OkeDungeon dungeon, Oke oke, String param) {
927931 String field[] = CHutil.split(param, ',');
928932 int direction = Integer.parseInt(field[0]);
@@ -931,6 +935,7 @@
931935 return dungeon.search_wall(oke, direction, range, distance);
932936 }
933937
938+ @Override
934939 public boolean edit(OkeSoftChip c, int x, int y,
935940 OkeSoftData d, String param) {
936941 String field[] = CHutil.split(param, ',');
@@ -1030,6 +1035,7 @@
10301035 OkeSoftSearchBullette() {
10311036 }
10321037
1038+ @Override
10331039 public boolean exec(OkeDungeon dungeon, Oke oke, String param) {
10341040 String field[] = CHutil.split(param, ',');
10351041 int direction = Integer.parseInt(field[0]);
@@ -1040,6 +1046,7 @@
10401046 return (bullette != null);
10411047 }
10421048
1049+ @Override
10431050 public boolean edit(OkeSoftChip c, int x, int y,
10441051 OkeSoftData d, String param) {
10451052 String field[] = CHutil.split(param, ',');
@@ -1138,6 +1145,7 @@
11381145 OkeSoftSearchParts() {
11391146 }
11401147
1148+ @Override
11411149 public boolean exec(OkeDungeon dungeon, Oke oke, String param) {
11421150 String field[] = CHutil.split(param, ',');
11431151 int direction = Integer.parseInt(field[0]);
@@ -1146,6 +1154,7 @@
11461154 return dungeon.search_parts(oke, direction, range, distance);
11471155 }
11481156
1157+ @Override
11491158 public boolean edit(OkeSoftChip c, int x, int y,
11501159 OkeSoftData d, String param) {
11511160 String field[] = CHutil.split(param, ',');
@@ -1249,6 +1258,7 @@
12491258 OkeSoftSearchStairs() {
12501259 }
12511260
1261+ @Override
12521262 public boolean exec(OkeDungeon dungeon, Oke oke, String param) {
12531263 String field[] = CHutil.split(param, ',');
12541264 int direction = Integer.parseInt(field[0]);
@@ -1258,6 +1268,7 @@
12581268 field[3].equals(stairs[0]));
12591269 }
12601270
1271+ @Override
12611272 public boolean edit(OkeSoftChip c, int x, int y,
12621273 OkeSoftData d, String param) {
12631274 String field[] = CHutil.split(param, ',');
@@ -1378,6 +1389,7 @@
13781389 OkeSoftFireMain() {
13791390 }
13801391
1392+ @Override
13811393 public boolean exec(OkeDungeon dungeon, Oke oke, String param) {
13821394 if (oke.get_bullette(0) > 0) {
13831395 String field[] = CHutil.split(param, ',');
@@ -1394,6 +1406,7 @@
13941406 return false;
13951407 }
13961408
1409+ @Override
13971410 public boolean edit(OkeSoftChip c, int x, int y,
13981411 OkeSoftData d, String param) {
13991412 String field[] = CHutil.split(param, ',');
@@ -1473,6 +1486,7 @@
14731486 OkeSoftFireSub() {
14741487 }
14751488
1489+ @Override
14761490 public boolean exec(OkeDungeon dungeon, Oke oke, String param) {
14771491 if (oke.get_bullette(1) > 0) {
14781492 String field[] = CHutil.split(param, ',');
@@ -1498,6 +1512,7 @@
14981512 return false;
14991513 }
15001514
1515+ @Override
15011516 public boolean edit(OkeSoftChip c, int x, int y,
15021517 OkeSoftData d, String param) {
15031518 String field[] = CHutil.split(param, ',');
@@ -1595,6 +1610,7 @@
15951610 OkeSoftFight() {
15961611 }
15971612
1613+ @Override
15981614 public boolean exec(OkeDungeon dungeon, Oke oke, String param) {
15991615 Oke target = dungeon.search_oke(true, oke, 0, 45, 3);
16001616 if (target != null) {
@@ -1603,6 +1619,7 @@
16031619 return false;
16041620 }
16051621
1622+ @Override
16061623 public boolean edit(OkeSoftChip c, int x, int y,
16071624 OkeSoftData d, String param) {
16081625 Dialog dialog = new Dialog(CarnageHack.getFrame(),
@@ -1651,11 +1668,13 @@
16511668 OkeSoftProne() {
16521669 }
16531670
1671+ @Override
16541672 public boolean exec(OkeDungeon dungeon, Oke oke, String param) {
16551673 oke.set_action(Oke.ACTION_PRONE);
16561674 return false;
16571675 }
16581676
1677+ @Override
16591678 public boolean edit(OkeSoftChip c, int x, int y,
16601679 OkeSoftData d, String param) {
16611680 Dialog dialog = new Dialog(CarnageHack.getFrame(),
@@ -1704,6 +1723,7 @@
17041723 OkeSoftStairs() {
17051724 }
17061725
1726+ @Override
17071727 public boolean exec(OkeDungeon dungeon, Oke oke, String param) {
17081728 if (dungeon.search_stairs(oke, 0, 20, 3, true) == true
17091729 || dungeon.search_stairs(oke, 0, 20, 3, false) == true) {
@@ -1712,6 +1732,7 @@
17121732 return false;
17131733 }
17141734
1735+ @Override
17151736 public boolean edit(OkeSoftChip c, int x, int y,
17161737 OkeSoftData d, String param) {
17171738 Dialog dialog = new Dialog(CarnageHack.getFrame(),
@@ -1756,6 +1777,7 @@
17561777 OkeSoftGet() {
17571778 }
17581779
1780+ @Override
17591781 public boolean exec(OkeDungeon dungeon, Oke oke, String param) {
17601782 if (dungeon.search_parts(oke, 0, 20, 3) == true) {
17611783 oke.set_action(Oke.ACTION_GET);
@@ -1763,6 +1785,7 @@
17631785 return false;
17641786 }
17651787
1788+ @Override
17661789 public boolean edit(OkeSoftChip c, int x, int y,
17671790 OkeSoftData d, String param) {
17681791 Dialog dialog = new Dialog(CarnageHack.getFrame(),
@@ -1811,11 +1834,13 @@
18111834 OkeSoftOption() {
18121835 }
18131836
1837+ @Override
18141838 public boolean exec(OkeDungeon dungeon, Oke oke, String param) {
18151839 oke.use_option();
18161840 return false;
18171841 }
18181842
1843+ @Override
18191844 public boolean edit(OkeSoftChip c, int x, int y,
18201845 OkeSoftData d, String param) {
18211846 Dialog dialog = new Dialog(CarnageHack.getFrame(),
@@ -1877,6 +1902,7 @@
18771902 OkeSoftRemain() {
18781903 }
18791904
1905+ @Override
18801906 public boolean exec(OkeDungeon dungeon, Oke oke, String param) {
18811907 String field[] = CHutil.split(param, ',');
18821908 int i;
@@ -1920,6 +1946,7 @@
19201946 return false;
19211947 }
19221948
1949+ @Override
19231950 public boolean edit(OkeSoftChip c, int x, int y,
19241951 OkeSoftData d, String param) {
19251952 String field[] = CHutil.split(param, ',');
@@ -2058,6 +2085,7 @@
20582085 OkeSoftFuel() {
20592086 }
20602087
2088+ @Override
20612089 public boolean exec(OkeDungeon dungeon, Oke oke, String param) {
20622090 String field[] = CHutil.split(param, ',');
20632091 int fuel = 0;
@@ -2094,6 +2122,7 @@
20942122 return false;
20952123 }
20962124
2125+ @Override
20972126 public boolean edit(OkeSoftChip c, int x, int y,
20982127 OkeSoftData d, String param) {
20992128 String field[] = CHutil.split(param, ',');
@@ -2216,6 +2245,7 @@
22162245 OkeSoftHp() {
22172246 }
22182247
2248+ @Override
22192249 public boolean exec(OkeDungeon dungeon, Oke oke, String param) {
22202250 String field[] = CHutil.split(param, ',');
22212251 int hp = 0;
@@ -2251,6 +2281,7 @@
22512281 return false;
22522282 }
22532283
2284+ @Override
22542285 public boolean edit(OkeSoftChip c, int x, int y,
22552286 OkeSoftData d, String param) {
22562287 String field[] = CHutil.split(param, ',');
@@ -2372,6 +2403,7 @@
23722403 OkeSoftHeat() {
23732404 }
23742405
2406+ @Override
23752407 public boolean exec(OkeDungeon dungeon, Oke oke, String param) {
23762408 String field[] = CHutil.split(param, ',');
23772409 int heat = 0;
@@ -2405,6 +2437,7 @@
24052437 return false;
24062438 }
24072439
2440+ @Override
24082441 public boolean edit(OkeSoftChip c, int x, int y,
24092442 OkeSoftData d, String param) {
24102443 String field[] = CHutil.split(param, ',');
@@ -2530,6 +2563,7 @@
25302563 OkeSoftCounter() {
25312564 }
25322565
2566+ @Override
25332567 public boolean exec(OkeDungeon dungeon, Oke oke, String param) {
25342568 String field[] = CHutil.split(param, ',');
25352569 int i;
@@ -2575,6 +2609,7 @@
25752609 return false;
25762610 }
25772611
2612+ @Override
25782613 public boolean edit(OkeSoftChip c, int x, int y,
25792614 OkeSoftData d, String param) {
25802615 String field[] = CHutil.split(param, ',');
@@ -2680,6 +2715,7 @@
26802715 OkeSoftCond() {
26812716 }
26822717
2718+ @Override
26832719 public boolean exec(OkeDungeon dungeon, Oke oke, String param) {
26842720 String field[] = CHutil.split(param, ',');
26852721 int i;
@@ -2716,6 +2752,7 @@
27162752 return false;
27172753 }
27182754
2755+ @Override
27192756 public boolean edit(OkeSoftChip c, int x, int y,
27202757 OkeSoftData d, String param) {
27212758 String field[] = CHutil.split(param, ',');
@@ -2842,6 +2879,7 @@
28422879 OkeSoftPartsInfo() {
28432880 }
28442881
2882+ @Override
28452883 public boolean exec(OkeDungeon dungeon, Oke oke, String param) {
28462884 String field[] = CHutil.split(param, ',');
28472885 int n = 0;
@@ -2895,6 +2933,7 @@
28952933 return false;
28962934 }
28972935
2936+ @Override
28982937 public boolean edit(OkeSoftChip c, int x, int y,
28992938 OkeSoftData d, String param) {
29002939 String field[] = CHutil.split(param, ',');
@@ -3025,6 +3064,7 @@
30253064 OkeSoftDropParts() {
30263065 }
30273066
3067+ @Override
30283068 public boolean exec(OkeDungeon dungeon, Oke oke, String param) {
30293069 int n = 0;
30303070 int i;
@@ -3050,6 +3090,7 @@
30503090 return false;
30513091 }
30523092
3093+ @Override
30533094 public boolean edit(OkeSoftChip c, int x, int y,
30543095 OkeSoftData d, String param) {
30553096 Dialog dialog = new Dialog(CarnageHack.getFrame(),
@@ -3123,6 +3164,7 @@
31233164 OkeSoftRandom() {
31243165 }
31253166
3167+ @Override
31263168 public boolean exec(OkeDungeon dungeon, Oke oke, String param) {
31273169 String field[] = CHutil.split(param, ',');
31283170 try {
@@ -3136,6 +3178,7 @@
31363178 return false;
31373179 }
31383180
3181+ @Override
31393182 public boolean edit(OkeSoftChip c, int x, int y,
31403183 OkeSoftData d, String param) {
31413184 String field[] = CHutil.split(param, ',');
@@ -3237,11 +3280,13 @@
32373280 OkeSoftChange() {
32383281 }
32393282
3283+ @Override
32403284 public boolean exec(OkeDungeon dungeon, Oke oke, String param) {
32413285 oke.change_software();
32423286 return false;
32433287 }
32443288
3289+ @Override
32453290 public boolean edit(OkeSoftChip c, int x, int y, OkeSoftData d,
32463291 String param) {
32473292 Dialog dialog = new Dialog(CarnageHack.getFrame(),
--- CarnageHack2/trunk/src/CarnageHack/OkeSoftFilter.java (revision 49)
+++ CarnageHack2/trunk/src/CarnageHack/OkeSoftFilter.java (revision 50)
@@ -20,6 +20,7 @@
2020 needdir = b;
2121 }
2222
23+ @Override
2324 public boolean accept(File dir, String name) {
2425 return accept(new File(dir, name));
2526 }
--- CarnageHack2/trunk/src/CarnageHack/OkeSoftEditCommonButton.java (revision 49)
+++ CarnageHack2/trunk/src/CarnageHack/OkeSoftEditCommonButton.java (revision 50)
@@ -27,6 +27,7 @@
2727 ok = false;
2828 }
2929
30+ @Override
3031 public void actionPerformed(ActionEvent e) {
3132 String wk = e.getActionCommand();
3233 if (wk.equals("OK") == true) {
--- CarnageHack2/trunk/src/CarnageHack/OkeHardCpu.java (revision 49)
+++ CarnageHack2/trunk/src/CarnageHack/OkeHardCpu.java (revision 50)
@@ -31,6 +31,7 @@
3131 weight = w;
3232 }
3333
34+ @Override
3435 public String get_category() {
3536 return "CPU";
3637 }
@@ -39,6 +40,7 @@
3940 return speed;
4041 }
4142
43+ @Override
4244 public void load(String s) {
4345 String field[] = CHutil.split(s, ',');
4446 name = field[0];
@@ -46,6 +48,7 @@
4648 weight = Integer.parseInt(field[2]);
4749 }
4850
51+ @Override
4952 public String save() {
5053 String s;
5154 s = name + "," + speed + "," + weight;
--- CarnageHack2/trunk/src/CarnageHack/OkeSoftPanel.java (revision 49)
+++ CarnageHack2/trunk/src/CarnageHack/OkeSoftPanel.java (revision 50)
@@ -637,6 +637,7 @@
637637 parent.dispose();
638638 }
639639
640+ @Override
640641 public void actionPerformed(ActionEvent e) {
641642 String cmd = e.getActionCommand();
642643 if (cmd.equals("OK") == true) {
--- CarnageHack2/trunk/src/CarnageHack/OkeHardPanel.java (revision 49)
+++ CarnageHack2/trunk/src/CarnageHack/OkeHardPanel.java (revision 50)
@@ -524,6 +524,7 @@
524524 }
525525 }
526526
527+ @Override
527528 public void action(String s, String item) {
528529 if (s.equals("MAINWEAPON") == true) {
529530 String wk = search_list(main_weapon_list, item);
@@ -620,6 +621,7 @@
620621 }
621622 }
622623
624+ @Override
623625 public void action(TextField text, String cmd) {
624626 if (cmd.equals("MAINBULLETTE") == true) {
625627 String wk = text.getText();
@@ -659,6 +661,7 @@
659661 update_total_weight();
660662 }
661663
664+ @Override
662665 public void actionPerformed(ActionEvent e) {
663666 String cmd = e.getActionCommand();
664667 if (cmd.equals("LOAD") == true) {
@@ -848,6 +851,7 @@
848851 reflect = r;
849852 }
850853
854+ @Override
851855 public void itemStateChanged(ItemEvent e) {
852856 if (e.getStateChange() == ItemEvent.SELECTED) {
853857 reflect.action(name, (String) e.getItem());
@@ -876,6 +880,7 @@
876880 name = s;
877881 }
878882
883+ @Override
879884 public void actionPerformed(ActionEvent e) {
880885 reflect.action((TextField) e.getSource(), name);
881886 }
--- CarnageHack2/trunk/src/CarnageHack/OkeSoftInputEditPane.java (revision 49)
+++ CarnageHack2/trunk/src/CarnageHack/OkeSoftInputEditPane.java (revision 50)
@@ -35,20 +35,24 @@
3535 add(text);
3636 }
3737
38+ @Override
3839 public void update_component() {
3940 TextField text = (TextField) getComponent(1);
4041 str = text.getText();
4142 }
4243
44+ @Override
4345 public void actionPerformed(ActionEvent e) {
4446 update_component();
4547 }
4648
49+ @Override
4750 public void focusGained(FocusEvent e) {
4851 TextField text = (TextField) e.getComponent();
4952 text.selectAll();
5053 }
5154
55+ @Override
5256 public void focusLost(FocusEvent e) {
5357 }
5458
@@ -99,6 +103,7 @@
99103 ifield2 = f2;
100104 }
101105
106+ @Override
102107 public void update_component() {
103108 ifield1.update_component();
104109 ifield2.update_component();
--- CarnageHack2/trunk/src/CarnageHack/OkeHardFuelTank.java (revision 49)
+++ CarnageHack2/trunk/src/CarnageHack/OkeHardFuelTank.java (revision 50)
@@ -31,6 +31,7 @@
3131 weight = w;
3232 }
3333
34+ @Override
3435 public String get_category() {
3536 return "FUELTANK";
3637 }
@@ -44,6 +45,7 @@
4445 return fuel;
4546 }
4647
48+ @Override
4749 public void load(String s) {
4850 String field[] = CHutil.split(s, ',');
4951 name = field[0];
@@ -51,6 +53,7 @@
5153 weight = Integer.parseInt(field[2]);
5254 }
5355
56+ @Override
5457 public String save() {
5558 String s;
5659 s = name + "," + fuel + "," + weight;
--- CarnageHack2/trunk/src/CarnageHack/OkeHardData.java (revision 49)
+++ CarnageHack2/trunk/src/CarnageHack/OkeHardData.java (revision 50)
@@ -205,10 +205,8 @@
205205 wk = r.readLine();
206206 option.load(wk);
207207 ret = true;
208- } catch (IOException e) {
208+ } catch (IOException | NumberFormatException e) {
209209 ret = false;
210- } catch (NumberFormatException e) {
211- ret = false;
212210 }
213211 return ret;
214212 }
@@ -221,9 +219,9 @@
221219 public void load(String fname) {
222220 boolean success;
223221 try {
224- BufferedReader r = new BufferedReader(new FileReader(fname));
225- success = load(r);
226- r.close();
222+ try (BufferedReader r = new BufferedReader(new FileReader(fname))) {
223+ success = load(r);
224+ }
227225 } catch (Exception e) {
228226 success = false;
229227 }
@@ -277,10 +275,10 @@
277275 public void save(String fname) {
278276 boolean success;
279277 try {
280- PrintWriter w
281- = new PrintWriter(new BufferedWriter(new FileWriter(fname)));
282- success = save(w);
283- w.close();
278+ try (PrintWriter w = new PrintWriter(new BufferedWriter(
279+ new FileWriter(fname)))) {
280+ success = save(w);
281+ }
284282 } catch (Exception e) {
285283 success = false;
286284 }
--- CarnageHack2/trunk/src/CarnageHack/CHmessageboxEvent.java (revision 49)
+++ CarnageHack2/trunk/src/CarnageHack/CHmessageboxEvent.java (revision 50)
@@ -26,6 +26,7 @@
2626 ok = false;
2727 }
2828
29+ @Override
2930 public void actionPerformed(ActionEvent e) {
3031 String cmd = e.getActionCommand();
3132 if (cmd.equals("OK") == true) {
--- CarnageHack2/trunk/src/CarnageHack/OkeHardArmor.java (revision 49)
+++ CarnageHack2/trunk/src/CarnageHack/OkeHardArmor.java (revision 50)
@@ -31,6 +31,7 @@
3131 weight = w;
3232 }
3333
34+ @Override
3435 public String get_category() {
3536 return "ARMOR";
3637 }
@@ -44,6 +45,7 @@
4445 return armor;
4546 }
4647
48+ @Override
4749 public void load(String s) {
4850 String field[] = CHutil.split(s, ',');
4951 name = field[0];
@@ -51,6 +53,7 @@
5153 weight = Integer.parseInt(field[2]);
5254 }
5355
56+ @Override
5457 public String save() {
5558 String s;
5659 s = name + "," + armor + "," + weight;
--- CarnageHack2/trunk/src/CarnageHack/OkeSoftChoiseEditPane.java (revision 49)
+++ CarnageHack2/trunk/src/CarnageHack/OkeSoftChoiseEditPane.java (revision 50)
@@ -40,6 +40,7 @@
4040 }
4141 }
4242
43+ @Override
4344 public void action(String s) {
4445 str = s;
4546 }
@@ -95,6 +96,7 @@
9596 name = s;
9697 }
9798
99+ @Override
98100 public void itemStateChanged(ItemEvent e) {
99101 if (e.getStateChange() == ItemEvent.SELECTED) {
100102 pane.action(name);
--- CarnageHack2/trunk/src/CarnageHack/OkeHardFilter.java (revision 49)
+++ CarnageHack2/trunk/src/CarnageHack/OkeHardFilter.java (revision 50)
@@ -20,6 +20,7 @@
2020 needdir = b;
2121 }
2222
23+ @Override
2324 public boolean accept(File dir, String name) {
2425 return accept(new File(dir, name));
2526 }
--- CarnageHack2/trunk/src/CarnageHack/OkeHardWeapon.java (revision 49)
+++ CarnageHack2/trunk/src/CarnageHack/OkeHardWeapon.java (revision 50)
@@ -57,6 +57,7 @@
5757 heat = h;
5858 }
5959
60+ @Override
6061 public String get_category() {
6162 return "WEAPON";
6263 }
@@ -115,6 +116,7 @@
115116 return heat;
116117 }
117118
119+ @Override
118120 public void load(String s) {
119121 String field[] = CHutil.split(s, ',');
120122 if (field[1].equals("A") == true) {
@@ -139,6 +141,7 @@
139141 heat = Integer.parseInt(field[7]);
140142 }
141143
144+ @Override
142145 public String save() {
143146 String s;
144147 s = name + ",";
--- CarnageHack2/trunk/src/CarnageHack/CarnageHack.java (revision 49)
+++ CarnageHack2/trunk/src/CarnageHack/CarnageHack.java (revision 50)
@@ -1,1101 +1,1083 @@
1-package CarnageHack;
2-
3-import java.lang.reflect.*;
4-import java.util.ResourceBundle;
5-import java.io.*;
6-import java.awt.*;
7-import java.awt.event.*;
8-import java.security.InvalidAlgorithmParameterException;
9-import java.security.InvalidKeyException;
10-import java.security.NoSuchAlgorithmException;
11-import java.util.Timer;
12-import java.util.logging.Level;
13-import java.util.logging.Logger;
14-import javax.crypto.Cipher;
15-import javax.crypto.CipherOutputStream;
16-import javax.crypto.CipherInputStream;
17-import javax.crypto.NoSuchPaddingException;
18-import javax.crypto.spec.IvParameterSpec;
19-import javax.crypto.spec.SecretKeySpec;
20-
21-/**
22- * CarnageHack メインパネル
23- *
24- * @author fukui
25- */
26-public final class CarnageHack extends Panel implements ActionListener {
27-
28- public static final String version = "CarnageHack2 V1.5.0 alpha";
29- public static final ResourceBundle resource;
30- public static CHArrayList main_weapon_list;
31- public static CHArrayList sub_weapon_list;
32- public static CHArrayList cpu_list;
33- public static CHArrayList engine_list;
34- public static CHArrayList armor_list;
35- public static CHArrayList fueltank_list;
36- public static CHArrayList option_list;
37- public static String npcsoftware[];
38- public static String npchardware[];
39- public static CHArrayList parts;
40- public static int update_timer;
41- public static CHArrayList collected_parts;
42- public static Point dungeonpos;
43- public static Point defaultpos;
44- public static Point chiptablepos;
45- public static Point softtablepos;
46- public static Dimension softtablesz;
47- public static Point hardwarepos;
48- public static Point stockpos;
49- private static Frame frame;
50- private static final String builtin_software[];
51- private OkeSoftData software;
52- private OkeSoftData software2;
53- private int current_edit_soft;
54- private OkeHardData hardware;
55- private static final long serialVersionUID = 1;
56- private static final String cryptPhase = "HageOyaji&Megane";
57- private static final String vectorPhase = "Manji2Developers";
58-
59- static {
60- resource = ResourceBundle.getBundle("CarnageHack/CarnageHack");
61- parts = new CHArrayList();
62- collected_parts = new CHArrayList();
63- main_weapon_list = new CHArrayList();
64- sub_weapon_list = new CHArrayList();
65- cpu_list = new CHArrayList();
66- engine_list = new CHArrayList();
67- armor_list = new CHArrayList();
68- fueltank_list = new CHArrayList();
69- option_list = new CHArrayList();
70- File f = new File("hige");
71- npcsoftware = f.list(new OkeSoftFilter(false));
72- npchardware = f.list(new OkeHardFilter(false));
73- builtin_software = new String[4];
74- builtin_software[0] = "soft001.chip";
75- builtin_software[1] = "soft002.chip";
76- builtin_software[2] = "soft003.chip";
77- builtin_software[3] = "soft004.chip";
78- update_timer = 10;
79- dungeonpos = new Point();
80- defaultpos = new Point();
81- chiptablepos = new Point(328 + 16, 0);
82- softtablepos = new Point();
83- softtablesz = new Dimension();
84- hardwarepos = new Point();
85- stockpos = new Point(320, 0);
86- }
87-
88- /**
89- * コンストラクタ
90- */
91- @SuppressWarnings("LeakingThisInConstructor")
92- CarnageHack() {
93- super();
94- load_master_data();
95- setLayout(new GridLayout(6, 1));
96- Button button = new Button(resource.getString("buttonHARDWARE"));
97- button.addActionListener(this);
98- button.setActionCommand("HARDWARE");
99- add(button);
100- button = new Button(resource.getString("buttonSOFTWARE_A"));
101- button.addActionListener(this);
102- button.setActionCommand("SOFTWARE");
103- add(button);
104- button = new Button(resource.getString("buttonSOFTWARE_B"));
105- button.addActionListener(this);
106- button.setActionCommand("SOFTWARE2");
107- add(button);
108- button = new Button(resource.getString("buttonDUNGEON"));
109- button.addActionListener(this);
110- button.setActionCommand("DUNGEON");
111- add(button);
112- button = new Button(resource.getString("buttonSTOCK"));
113- button.addActionListener(this);
114- button.setActionCommand("VIEWPARTS");
115- add(button);
116- button = new Button(resource.getString("buttonEXIT"));
117- button.addActionListener(this);
118- button.setActionCommand("EXIT");
119- add(button);
120- load_setup();
121- load_data();
122- }
123-
124- /**
125- * 100面体ダイス
126- *
127- * @return 0から99の乱数
128- */
129- public static int dice100() {
130- return (int) Math.floor(Math.random() * 100);
131- }
132-
133- /**
134- * ソフトウェアの新規作成
135- *
136- * @param obj JARオブジェクト
137- * @return ソフトウェアデータ
138- */
139- public static OkeSoftData makeNewSoft(Object obj) {
140- int nmax = (npcsoftware == null) ? 0 : Array.getLength(npcsoftware);
141- if (nmax > 0) {
142- int n = (int) Math.floor(Math.random() * nmax);
143- OkeSoftData data = new OkeSoftData();
144- data.load("hige/" + npcsoftware[n]);
145- return data;
146- } else {
147- int n = (int) Math.floor(Math.random() * builtin_software.length);
148- OkeSoftData data = new OkeSoftData();
149- InputStream fis = obj.getClass().
150- getResourceAsStream("hige/" + builtin_software[n]);
151- InputStreamReader isr = new InputStreamReader(fis);
152- BufferedReader fin = new BufferedReader(isr);
153- data.load(fin);
154- return data;
155- }
156- }
157-
158- /**
159- * ハードウェアの新規作成
160- *
161- * @return ハードウェアデータ
162- */
163- public static OkeHardData makeNewHard() {
164- int nmax = (npchardware == null) ? 0 : Array.getLength(npchardware);
165- OkeHardData data = new OkeHardData();
166- if (nmax == 0 || dice100() > 50) {
167- //auto build
168- int target_weight;
169- data.get_mainweapon().load(auto_select(main_weapon_list));
170- data.set_main_bullette(
171- (int) Math.floor(Math.random() * 20) * 10 + 10);
172- data.get_subweapon().load(auto_select(sub_weapon_list));
173- data.set_sub_bullette((int) Math.floor(Math.random() * 48) + 1);
174- data.get_cpu().load(auto_select(cpu_list));
175- data.get_engine().load(auto_select(engine_list));
176- data.get_armor().load(auto_select(armor_list));
177- data.get_fueltank().load(auto_select(fueltank_list));
178- if (dice100() > 60) {
179- data.get_option().load(auto_select(option_list));
180- }
181- if (dice100() > 60) {
182- target_weight
183- = (int) Math.floor(data.get_engine().get_max_weight()
184- * 1.5);
185- } else {
186- target_weight = data.get_engine().get_max_weight();
187- }
188- while (target_weight < data.get_total_weight()) {
189- //over weight
190- int w1 = data.get_main_bullette();
191- int w2 = data.get_sub_bullette();
192- if (w1 == 0 && w2 == 0) {
193- //can't adjust
194- break;
195- }
196- if (data.get_mainweapon().get_weight() * w1
197- > data.get_subweapon().get_weight() * w2) {
198- w1--;
199- data.set_main_bullette(w1);
200- } else if (w2 > 0) {
201- w2--;
202- data.set_sub_bullette(w2);
203- } else {
204- //can't adjust
205- break;
206- }
207- }
208- } else {
209- data.load("hige/" + npchardware[(int) Math.floor(Math.random()
210- * nmax)]);
211- }
212- return data;
213- }
214-
215- /**
216- * 指定された配列データから無作為に選択
217- *
218- * @param list 配列データ
219- * @return 選択した要素
220- */
221- static String auto_select(CHArrayList list) {
222- int nmax = list.size();
223- return (String) list.get((int) Math.floor(Math.random() * nmax));
224- }
225-
226- /**
227- * 指定された名称のデータが配列内にあるかどうかを確認
228- *
229- * @param list 配列データ
230- * @param name 名称
231- * @return 存在するときにtrue
232- */
233- boolean haveparts(CHArrayList list, String name) {
234- String wk = (String) list.get(0);
235- String field[] = CHutil.split(wk, ',', 2);
236- if (field[0].equals(name) == false) {
237- return (search_parts(name) != -1);
238- }
239- return true;
240- }
241-
242- /**
243- * 設定された機体で出撃可能かどうかをチェック
244- *
245- * @return 出撃可能な時にtrue
246- */
247- boolean check_oke_parts() {
248- return !(haveparts(main_weapon_list,
249- hardware.get_mainweapon().get_name()) == false
250- || haveparts(sub_weapon_list,
251- hardware.get_subweapon().get_name()) == false
252- || haveparts(cpu_list, hardware.get_cpu().get_name()) == false
253- || haveparts(engine_list,
254- hardware.get_engine().get_name()) == false
255- || haveparts(armor_list,
256- hardware.get_armor().get_name()) == false
257- || haveparts(fueltank_list,
258- hardware.get_fueltank().get_name()) == false
259- || haveparts(option_list,
260- hardware.get_option().get_name()) == false);
261- }
262-
263- /**
264- * 出撃に伴うパーツの在庫更新
265- *
266- * @return 出撃成功時にtrue
267- */
268- boolean update_parts() {
269- if (check_oke_parts() == false) {
270- return false;
271- }
272- delete_parts(hardware.get_mainweapon().get_name(),
273- hardware.get_main_bullette());
274- delete_parts(hardware.get_subweapon().get_name(),
275- hardware.get_sub_bullette());
276- delete_parts(hardware.get_cpu().get_name(), 1);
277- delete_parts(hardware.get_engine().get_name(), 1);
278- delete_parts(hardware.get_armor().get_name(), 1);
279- delete_parts(hardware.get_fueltank().get_name(), 1);
280- delete_parts(hardware.get_option().get_name(), 1);
281- return true;
282- }
283-
284- /**
285- * 指定されたOKEがパーツを回収
286- *
287- * @param oke OKEデータ
288- */
289- void collect_parts(Oke oke) {
290- int nmax = oke.get_backpack_count();
291- if (nmax > 0) {
292- //you get back parts
293- int i;
294- for (i = 0; i < nmax; i++) {
295- String field[] = CHutil.split(oke.get_backpack(i), ':', 3);
296- String wk;
297- add_parts(field[0], field[2], Integer.parseInt(field[1]));
298- wk = field[0] + ":" + field[1] + ":";
299- field = CHutil.split(field[2], ',', 2);
300- wk += field[0];
301- collected_parts.add(wk);
302- }
303- collected_parts.sort();
304- parts.sort();
305- }
306- }
307-
308- /**
309- * ダンジョンへ出撃
310- */
311- boolean dungeon_go(boolean bauto) {
312- save_data(); //save data now! :D
313- collected_parts.clear();
314- //process dungeon...
315- Dialog dialog = new Dialog(frame, resource.getString(
316- "titleDUNGEON"), true);
317- Oke myoke = new Oke(Oke.IFF_FRIEND, 1000, hardware, software,
318- software2);
319- OkeDungeon dungeon = new OkeDungeon(dialog, myoke);
320- CarnageHackDialogEvent chevent
321- = new CarnageHackDialogEvent(dialog, dungeon);
322- dungeon.start_timer();
323- dialog.add(dungeon, BorderLayout.CENTER);
324- dialog.addWindowListener(chevent);
325- Button button;
326- button = new Button(CarnageHack.resource.
327- getString("buttonDisconnect"));
328- button.setActionCommand("OK");
329- button.addActionListener(chevent);
330- dialog.add(button, BorderLayout.SOUTH);
331- dialog.pack();
332- dialog.setLocation(dungeonpos);
333- dialog.setVisible(true);
334- dialog.getLocation(dungeonpos);
335- dungeon.close_status();
336- //display tombstone or goal screen
337- Toolkit tk = Toolkit.getDefaultToolkit();
338- String mesg;
339- Image icon;
340- if (dungeon.get_goalin() == true) {
341- collect_parts(myoke);
342- save_data(); //save data again! :D
343- mesg = resource.getString("RTBmessage");
344- if (dungeon.is_havehige() == true) {
345- mesg += resource.getString("SuccessMessage");
346- icon = tk.getImage(getClass().
347- getResource("icon/success.png"));
348- } else {
349- mesg += resource.getString("FailMessage");
350- icon = tk.getImage(getClass().
351- getResource("icon/failed.png"));
352- }
353- } else {
354- if (myoke.isdead() == true) {
355- mesg = resource.getString("DestroyMessage");
356- switch (myoke.get_reason()) {
357- case Oke.DAMAGE_DESTRUCT:
358- if (myoke.get_attacker() == myoke) {
359- mesg
360- += resource.getString(
361- "ReasonSelfDestruct");
362- } else {
363- mesg += resource.getString(
364- "ReasonDestruct");
365- }
366- break;
367- case Oke.DAMAGE_HEAT:
368- mesg += resource.getString("ReasonHeat");
369- break;
370- case Oke.DAMAGE_FIGHT:
371- mesg += resource.getString("ReasonFight");
372- break;
373- case Oke.DAMAGE_ASSALUT:
374- mesg += resource.getString("ReasonAssalut");
375- break;
376- case Oke.DAMAGE_LASER:
377- mesg += resource.getString("ReasonLaser");
378- break;
379- case Oke.DAMAGE_SHOTGUN:
380- mesg += resource.getString("ReasonShotgun");
381- break;
382- case Oke.DAMAGE_MISSILE:
383- mesg += resource.getString("ReasonMissile");
384- break;
385- case Oke.DAMAGE_ROCKET:
386- mesg += resource.getString("ReasonRocket");
387- break;
388- default:
389- mesg += resource.getString("ReasonNone");
390- break;
391- }
392- mesg += resource.getString("DestroyMessage2")
393- + (myoke.get_floor() + 1)
394- + resource.getString("DestroyMessage3");
395- } else {
396- mesg = resource.getString("QuitMessage");
397- }
398- icon = tk.getImage(getClass().
399- getResource("icon/tombstone.png"));
400- }
401- mesg += resource.getString("OkeScoreMessage1")
402- + myoke.get_destroycount()
403- + resource.getString("OkeScoreMessage2");
404- if (collected_parts.size() > 0) {
405- mesg += resource.getString("OkeScoreMessage3")
406- + collected_parts.size()
407- + resource.getString("OkeScoreMessage4");
408- }
409- mesg += resource.getString("MaximumFloorMessage")
410- + dungeon.get_maximum_floor()
411- + resource.getString("MaximumFloorMessage2");
412- //ユーザーがボタンを押したら自動実行を解除
413- bauto = CHutil.MessageBox(mesg, resource.getString("ReportTitle"),
414- icon, false, 10000) != true;
415- if (collected_parts.size() > 0) {
416- Timer timer = null;
417- CHtimerAutoClose ttask = null;
418- Dialog clist
419- = new Dialog(frame, resource.getString(
420- "titlePARTS_LIST"), true);
421- List list = new List(20);
422- CHmessageboxEvent msgevent = new CHmessageboxEvent(clist);
423- int i;
424- for (i = 0; i < collected_parts.size(); i++) {
425- list.add((String) collected_parts.get(i));
426- }
427- clist.add(list, BorderLayout.CENTER);
428- clist.addWindowListener(msgevent);
429- button = new Button(
430- CarnageHack.resource.getString("buttonOK"));
431- button.setActionCommand("OK");
432- button.addActionListener(msgevent);
433- clist.add(button, BorderLayout.SOUTH);
434- clist.setSize(320, 400);
435- clist.setLocationRelativeTo(frame);
436- if (bauto == true) {
437- timer = new Timer();
438- ttask = new CHtimerAutoClose(clist);
439- ttask.set_button(button, button.getLabel());
440- ttask.set_timeout(5000);
441- timer.schedule(ttask, 0, 1000);
442- }
443- clist.setVisible(true);
444- if (timer != null) {
445- timer.cancel();
446- }
447- if (ttask != null) {
448- ttask.cancel();
449- }
450- }
451- return bauto;
452- }
453-
454- private void edit_software(int nsoft, String title, OkeSoftData sd) {
455- //build up software
456- Dialog dialog = new Dialog(frame, title, false);
457- OkeSoftPanel softpanel
458- = new OkeSoftPanel(this, frame, dialog, sd);
459- ScrollPane scrpane = new ScrollPane(ScrollPane.SCROLLBARS_ALWAYS);
460- current_edit_soft = nsoft;
461- scrpane.add(softpanel);
462- scrpane.setSize(328, 328);
463- dialog.add(scrpane);
464- dialog.pack();
465- dialog.setLocation(softtablepos);
466- if (softtablesz.width != 0 && softtablesz.height != 0) {
467- dialog.setSize(softtablesz);
468- }
469- frame.setEnabled(false);
470- dialog.setVisible(true);
471- }
472-
473- public void actionPerformed(ActionEvent e) {
474- String cmd = e.getActionCommand();
475- if (cmd.equals("SOFTWARE") == true) {
476- //build up software
477- edit_software(1, resource.getString("buttonSOFTWARE_A"), software);
478- } else if (cmd.equals("SOFTWARE2") == true) {
479- //build up software 2
480- edit_software(2, resource.getString("buttonSOFTWARE_B"), software2);
481- } else if (cmd.equals("HARDWARE") == true) {
482- //build up hardware
483- Dialog dialog = new Dialog(frame, resource.getString(
484- "buttonHARDWARE"), true);
485- CHmessageboxEvent msgevent = new CHmessageboxEvent(dialog);
486- OkeHardPanel hardpanel = new OkeHardPanel(hardware);
487- hardware = hardpanel.get_hardware();
488- dialog.add(hardpanel, BorderLayout.CENTER);
489- dialog.addWindowListener(msgevent);
490- Button button;
491- button = new Button(CarnageHack.resource.getString("buttonOK"));
492- button.setActionCommand("OK");
493- button.addActionListener(msgevent);
494- dialog.add(button, BorderLayout.SOUTH);
495- dialog.pack();
496- dialog.setLocation(hardwarepos);
497- dialog.setVisible(true);
498- dialog.getLocation(hardwarepos);
499- } else if (cmd.equals("DUNGEON") == true) {
500- if (software != null && software.get(0, 0) != null && hardware
501- != null) {
502- //go to dungeon!
503- boolean bauto = false;
504- do {
505- if (check_oke_parts() == false) { //check used parts
506- //don't have parts
507- CHutil.MessageBox(resource.getString("noParts"),
508- resource.getString("noPartsTitle"),
509- null, false);
510- return;
511- }
512- if (bauto == false) {
513- if (CHutil.MessageBox(resource.getString("confirmGoTo"),
514- resource.getString("confirmGoToTitle"),
515- null, true) == false) {
516- return;
517- }
518- bauto = true;
519- } else {
520- if (CHutil.MessageBox(
521- resource.getString("confirmAutoGo"),
522- resource.getString("confirmGoToTitle"),
523- null, false, 5000) == true) {
524- return;
525- }
526- }
527- if (update_parts() == false) {
528- //huh?
529- CHutil.MessageBox(resource.getString("noParts"),
530- resource.getString("noPartsTitle"),
531- null, false);
532- return;
533- }
534- bauto = dungeon_go(bauto);
535- } while (bauto);
536- } else {
537- CHutil.MessageBox(resource.getString("ngGoTo"),
538- resource.getString("ngGoToTitle"),
539- null, false);
540- }
541- } else if (cmd.equals("VIEWPARTS") == true) {
542- //view current parts
543- Dialog dialog = new Dialog(frame, resource.getString("titlePARTS"),
544- true);
545- CHmessageboxEvent msgevent = new CHmessageboxEvent(dialog);
546- List list = new List(20);
547- int i;
548- for (i = 0; i < parts.size(); i++) {
549- String wk = (String) parts.get(i);
550- String field[] = CHutil.split(wk, ':', 3);
551- wk = field[0] + ":" + field[1] + ":";
552- field = CHutil.split(field[2], ',', 2);
553- wk += field[0];
554- list.add(wk);
555- }
556- dialog.add(list, BorderLayout.CENTER);
557- dialog.addWindowListener(msgevent);
558- Button button;
559- button = new Button(CarnageHack.resource.getString("buttonOK"));
560- button.setActionCommand("OK");
561- button.addActionListener(msgevent);
562- dialog.add(button, BorderLayout.SOUTH);
563- dialog.setLocation(stockpos);
564- dialog.setSize(320, 400);
565- dialog.setVisible(true);
566- dialog.getLocation(stockpos);
567- } else if (cmd.equals("EXIT") == true) {
568- save_setup();
569- frame.dispose();
570- }
571- }
572-
573- /**
574- * パーツ検索
575- *
576- * @param name 名称
577- * @return 発見したインデックス。 見つからないときに-1
578- */
579- public static int search_parts(String name) {
580- int i;
581- int nmax = parts.size();
582- for (i = 0; i < nmax; i++) {
583- String wk = (String) parts.get(i);
584- String field[] = CHutil.split(wk, ':', 3);
585- wk = field[2];
586- field = CHutil.split(wk, ',', 2);
587- if (field[0].equals(name) == true) {
588- return i;
589- }
590- }
591- return -1;
592- }
593-
594- /**
595- * 指定した番号のパーツを削除
596- *
597- * @param name 名称
598- * @param n インデックス
599- */
600- public static void delete_parts(String name, int n) {
601- int idx = search_parts(name);
602- if (idx >= 0) {
603- String wk = (String) parts.get(idx);
604- String field[] = CHutil.split(wk, ':', 3);
605- int nwk = Integer.parseInt(field[1]);
606- nwk -= n;
607- if (nwk <= 0) {
608- parts.remove(idx);
609- } else {
610- parts.set(idx, field[0] + ":" + nwk + ":" + field[2]);
611- }
612- }
613- }
614-
615- /**
616- * パーツを追加
617- *
618- * @param t パーツタイプ
619- * @param s パーツデータ
620- * @param n パーツ数
621- */
622- public static void add_parts(String t, String s, int n) {
623- int i;
624- String field[];
625- String wk;
626- String name;
627- field = CHutil.split(s, ',', 2);
628- name = field[0];
629- i = search_parts(name);
630- if (i >= 0) {
631- wk = (String) parts.get(i);
632- field = CHutil.split(wk, ':', 3);
633- int nwk = Integer.parseInt(field[1]) + n;
634- parts.set(i, field[0] + ":" + nwk + ":" + field[2]);
635- } else {
636- parts.add(t + ":" + n + ":" + s);
637- }
638- }
639-
640- /**
641- * 指定されたパーツが初期パーツかどうかを確認
642- *
643- * @param t パーツタイプ
644- * @param s パーツデータ
645- * @return
646- */
647- public static boolean isdefaultparts(String t, String s) {
648- if (t.equals("M") == true) {
649- return s.equals((String) main_weapon_list.get(0));
650- } else if (t.equals("S") == true) {
651- return s.equals((String) sub_weapon_list.get(0));
652- } else if (t.equals("C") == true) {
653- return s.equals((String) cpu_list.get(0));
654- } else if (t.equals("E") == true) {
655- return s.equals((String) engine_list.get(0));
656- } else if (t.equals("A") == true) {
657- return s.equals((String) armor_list.get(0));
658- } else if (t.equals("F") == true) {
659- return s.equals((String) fueltank_list.get(0));
660- } else if (t.equals("O") == true) {
661- return s.equals((String) option_list.get(0));
662- }
663- return false;
664- }
665-
666- /**
667- * パーツを生成する
668- *
669- * @return 生成したパーツ(タイプ:名称:数量)
670- */
671- static public String generate_parts() {
672- String partsdata = new String();
673- int n = (int) Math.floor(Math.random() * 7);
674- CHArrayList list;
675- String t;
676- int ncount = 1;
677- switch (n) {
678- case 0:
679- list = CarnageHack.main_weapon_list;
680- ncount = ((int) Math.floor(Math.random() * 10) + 1) * 10;
681- t = "M";
682- break;
683- case 1:
684- list = CarnageHack.sub_weapon_list;
685- ncount = (int) Math.floor(Math.random() * 24) + 1;
686- t = "S";
687- break;
688- case 2:
689- list = CarnageHack.cpu_list;
690- t = "C";
691- break;
692- case 3:
693- list = CarnageHack.engine_list;
694- t = "E";
695- break;
696- case 4:
697- list = CarnageHack.armor_list;
698- t = "A";
699- break;
700- case 5:
701- list = CarnageHack.fueltank_list;
702- t = "F";
703- break;
704- case 6:
705- list = CarnageHack.option_list;
706- t = "O";
707- break;
708- default:
709- list = null;
710- t = null;
711- break;
712- }
713- if (list != null) {
714- int m = list.size() - 1;
715- partsdata = t + ":";
716- partsdata += (String) list.get((int) Math.floor(Math.random() * m)
717- + 1) + ":";
718- partsdata += ncount;
719- }
720- return partsdata;
721- }
722-
723- /**
724- * パーツマスタデータの読み込み
725- */
726- void load_master_data() {
727- try {
728- InputStream fis = getClass().
729- getResourceAsStream(resource.getString("namePartsData"));
730- InputStreamReader isr = new InputStreamReader(fis,
731- resource.getString("codingPartsData"));
732- BufferedReader r = new BufferedReader(isr);
733- String wkline;
734- while ((wkline = r.readLine()) != null) {
735- String field[] = CHutil.split(wkline, ':', 2);
736- if (field[0].equals("M") == true) {
737- //main weapon
738- main_weapon_list.add(field[1]);
739- } else if (field[0].equals("S") == true) {
740- //sub weapon
741- sub_weapon_list.add(field[1]);
742- } else if (field[0].equals("C") == true) {
743- //cpu
744- cpu_list.add(field[1]);
745- } else if (field[0].equals("E") == true) {
746- //engine
747- engine_list.add(field[1]);
748- } else if (field[0].equals("A") == true) {
749- //armor
750- armor_list.add(field[1]);
751- } else if (field[0].equals("F") == true) {
752- //fuel tank
753- fueltank_list.add(field[1]);
754- } else if (field[0].equals("O") == true) {
755- //option
756- option_list.add(field[1]);
757- }
758- }
759- r.close();
760- } catch (Exception e) {
761- CHutil.MessageBox(resource.getString("loadErr"),
762- resource.getString("loadErrTitle"),
763- null, false);
764- }
765- }
766-
767- /**
768- * 初期所持パーツの配布
769- */
770- static void initialize_inventory() {
771- int i;
772- String[] field;
773- for (i = 0; i < 10; i++) {
774- field = CHutil.split(generate_parts(), ':', 3);
775- add_parts(field[0], field[1], Integer.parseInt(field[2], 10));
776- }
777- }
778-
779- /**
780- * 暗号化データの取得
781- *
782- * @param opmode 暗号化モード
783- * @return 初期化済み暗号化オブジェクト
784- */
785- static public Cipher generateCipher(int opmode) {
786- try {
787- SecretKeySpec skey
788- = new SecretKeySpec(cryptPhase.getBytes("UTF-8"), "AES");
789- IvParameterSpec iv
790- = new IvParameterSpec(vectorPhase.getBytes("UTF-8"));
791- Cipher ci = Cipher.getInstance("AES/CBC/PKCS5PADDING");
792- ci.init(opmode, skey, iv);
793- return ci;
794- } catch (UnsupportedEncodingException ex) {
795- Logger.getLogger(CarnageHack.class.getName()).
796- log(Level.SEVERE, null, ex);
797- } catch (NoSuchAlgorithmException ex) {
798- Logger.getLogger(CarnageHack.class.getName()).
799- log(Level.SEVERE, null, ex);
800- } catch (NoSuchPaddingException ex) {
801- Logger.getLogger(CarnageHack.class.getName()).
802- log(Level.SEVERE, null, ex);
803- } catch (InvalidKeyException ex) {
804- Logger.getLogger(CarnageHack.class.getName()).
805- log(Level.SEVERE, null, ex);
806- } catch (InvalidAlgorithmParameterException ex) {
807- Logger.getLogger(CarnageHack.class.getName()).
808- log(Level.SEVERE, null, ex);
809- }
810- return null;
811- }
812-
813- /**
814- * 在庫パーツデータの読み込み
815- */
816- static void load_data() {
817- boolean bnewUser = false;
818- try {
819- Cipher ci = generateCipher(Cipher.DECRYPT_MODE);
820- String wkdir = System.getProperty("user.home", ".");
821- CipherInputStream is = new CipherInputStream(
822- new FileInputStream(wkdir + "/CarnageHack2.save"), ci);
823- BufferedReader r = new BufferedReader(new InputStreamReader(is));
824- String wkline;
825- parts.clear();
826- while ((wkline = r.readLine()) != null) {
827- parts.add(wkline);
828- }
829- parts.sort();
830- r.close();
831- } catch (IOException e) {
832- CHutil.MessageBox(resource.getString("newUser"),
833- resource.getString("newUserTitle"),
834- null, false);
835- bnewUser = true;
836- }
837- if (bnewUser == true) {
838- //新規ユーザーにはいくつかパーツを配布
839- initialize_inventory();
840- }
841- }
842-
843- /**
844- * 在庫パーツデータの保存
845- */
846- static void save_data() {
847- try {
848- Cipher ci = generateCipher(Cipher.ENCRYPT_MODE);
849- String wkdir = System.getProperty("user.home", ".");
850- CipherOutputStream os = new CipherOutputStream(
851- new FileOutputStream(wkdir
852- + "/CarnageHack2.save"), ci);
853- BufferedWriter w = new BufferedWriter(new OutputStreamWriter(os));
854- int i;
855- for (i = 0; i < parts.size(); i++) {
856- String wk = (String) parts.get(i);
857- w.write(wk, 0, wk.length());
858- w.newLine();
859- }
860- w.close();
861- os.close();
862- } catch (IOException e) {
863- CHutil.MessageBox(resource.getString("saveErr"),
864- resource.getString("saveErrTitle"),
865- null, false);
866- }
867- }
868-
869- /**
870- * 表示更新間隔を取得
871- *
872- * @return 表示更新間隔
873- */
874- static int get_update_timer() {
875- return update_timer;
876- }
877-
878- /**
879- * 表示更新間隔を設定
880- *
881- * @param n 表示更新間隔
882- */
883- static void set_update_timer(int n) {
884- update_timer = n;
885- }
886-
887- /**
888- * 設定値の読み込み
889- */
890- static void load_setup() {
891- try {
892- String wkdir = System.getProperty("user.home", ".");
893- BufferedReader r
894- = new BufferedReader(new FileReader(wkdir
895- + "/CarnageHack2.setup"));
896- String wkline;
897- while ((wkline = r.readLine()) != null) {
898- String field[] = CHutil.split(wkline, ',');
899- if (field[0].equals("UPDATE") == true) {
900- update_timer = Integer.parseInt(field[1]);
901- if (update_timer < 1) {
902- update_timer = 1;
903- }
904- } else if (field[0].equals("DUNGEONVIEW") == true) {
905- int w = Integer.parseInt(field[1]);
906- int h = Integer.parseInt(field[2]);
907- if (w < 100) {
908- w = 100;
909- }
910- if (h < 100) {
911- h = 100;
912- }
913- OkeDungeon.Width = w;
914- OkeDungeon.Height = h;
915- } else if (field[0].endsWith("DUNGEONPOS") == true) {
916- int x = Integer.parseInt(field[1]);
917- int y = Integer.parseInt(field[2]);
918- dungeonpos.setLocation(x, y);
919- } else if (field[0].endsWith("MAINWINDOW") == true) {
920- int x = Integer.parseInt(field[1]);
921- int y = Integer.parseInt(field[2]);
922- defaultpos.setLocation(x, y);
923- } else if (field[0].endsWith("SOFTTABLE") == true) {
924- int x = Integer.parseInt(field[1]);
925- int y = Integer.parseInt(field[2]);
926- softtablepos.setLocation(x, y);
927- } else if (field[0].endsWith("SOFTTABLESIZE") == true) {
928- int hx = Integer.parseInt(field[1]);
929- int hy = Integer.parseInt(field[2]);
930- softtablesz.setSize(hx, hy);
931- } else if (field[0].endsWith("CHIPTABLE") == true) {
932- int x = Integer.parseInt(field[1]);
933- int y = Integer.parseInt(field[2]);
934- chiptablepos.setLocation(x, y);
935- } else if (field[0].endsWith("HARDWARE") == true) {
936- int x = Integer.parseInt(field[1]);
937- int y = Integer.parseInt(field[2]);
938- hardwarepos.setLocation(x, y);
939- } else if (field[0].endsWith("STOCK") == true) {
940- int x = Integer.parseInt(field[1]);
941- int y = Integer.parseInt(field[2]);
942- stockpos.setLocation(x, y);
943- } else if (field[0].endsWith("SOFTWAREDIR") == true) {
944- OkeSoftPanel.setDataDir(field[1]);
945- } else if (field[0].endsWith("HARDWAREDIR") == true) {
946- OkeHardPanel.setDataDir(field[1]);
947- }
948- }
949- r.close();
950- } catch (IOException e) {
951- } catch (NumberFormatException e) {
952- }
953- }
954-
955- /**
956- * 設定値の保存
957- */
958- static void save_setup() {
959- try {
960- Point wkpos;
961- String wkdir = System.getProperty("user.home", ".");
962- BufferedWriter w
963- = new BufferedWriter(new FileWriter(wkdir
964- + "/CarnageHack2.setup"));
965- String wkline;
966- wkline = "UPDATE," + update_timer;
967- w.write(wkline, 0, wkline.length());
968- w.newLine();
969- wkline = "DUNGEONVIEW," + OkeDungeon.Width + ","
970- + OkeDungeon.Height;
971- w.write(wkline, 0, wkline.length());
972- w.newLine();
973- wkline = "DUNGEONPOS," + dungeonpos.x + "," + dungeonpos.y;
974- w.write(wkline, 0, wkline.length());
975- w.newLine();
976- wkpos = frame.getLocation();
977- wkline = "MAINWINDOW," + wkpos.x + "," + wkpos.y;
978- w.write(wkline, 0, wkline.length());
979- w.newLine();
980- wkline = "SOFTTABLE," + softtablepos.x + "," + softtablepos.y;
981- w.write(wkline, 0, wkline.length());
982- w.newLine();
983- wkline = "SOFTTABLESIZE," + softtablesz.width + ","
984- + softtablesz.height;
985- w.write(wkline, 0, wkline.length());
986- w.newLine();
987- wkline = "CHIPTABLE," + chiptablepos.x + "," + chiptablepos.y;
988- w.write(wkline, 0, wkline.length());
989- w.newLine();
990- wkline = "HARDWARE," + hardwarepos.x + "," + hardwarepos.y;
991- w.write(wkline, 0, wkline.length());
992- w.newLine();
993- wkline = "STOCK," + stockpos.x + "," + stockpos.y;
994- w.write(wkline, 0, wkline.length());
995- w.newLine();
996- wkline = "SOFTWAREDIR," + OkeSoftPanel.getDataDir();
997- w.write(wkline, 0, wkline.length());
998- w.newLine();
999- wkline = "HARDWAREDIR," + OkeHardPanel.getDataDir();
1000- w.write(wkline, 0, wkline.length());
1001- w.newLine();
1002- w.close();
1003- } catch (Exception e) {
1004- }
1005- }
1006-
1007- /**
1008- * 出撃用ソフトウェアを設定
1009- *
1010- * @param soft ソフトウェアデータ
1011- */
1012- public void set_software(OkeSoftData soft) {
1013- if (current_edit_soft == 1) {
1014- software = soft;
1015- } else {
1016- software2 = soft;
1017- }
1018- }
1019-
1020- /**
1021- * メイン
1022- *
1023- * @param args
1024- */
1025- public static void main(String[] args) {
1026- System.out.println(version + " Copyright by T.Fukui 2007-2015");
1027- frame = new Frame(version);
1028- CHutil.SplashBox(version);
1029- frame.add(new CarnageHack());
1030- frame.addWindowListener(new CarnageHackWindowEvent());
1031- frame.setSize(320, 200);
1032- frame.setLocation(defaultpos);
1033- frame.setVisible(true);
1034- }
1035-
1036- /**
1037- * フレームウィンドウ取得
1038- *
1039- * @return フレームウィンドウ
1040- */
1041- public static Frame getFrame() {
1042- return frame;
1043- }
1044-}
1045-
1046-/**
1047- * ウィンドウイベントハンドラ
1048- *
1049- * @author fukui
1050- */
1051-class CarnageHackWindowEvent extends WindowAdapter {
1052-
1053- @Override
1054- public void windowClosing(WindowEvent e) {
1055- CarnageHack.save_setup();
1056- System.exit(0);
1057- }
1058-}
1059-
1060-/**
1061- * ダンジョンウィンドウイベントハンドラ
1062- *
1063- * @author fukui
1064- */
1065-class CarnageHackDialogEvent extends WindowAdapter implements ActionListener {
1066-
1067- Dialog dialog;
1068- OkeDungeon dungeon;
1069-
1070- /**
1071- * コンストラクタ
1072- *
1073- * @param d ダンジョンデータ
1074- */
1075- CarnageHackDialogEvent(Dialog dlg, OkeDungeon d) {
1076- super();
1077- dialog = dlg;
1078- dungeon = d;
1079- }
1080-
1081- @Override
1082- public void windowClosing(WindowEvent e) {
1083- if (dungeon != null) {
1084- dungeon.force_end();
1085- }
1086- dialog.dispose();
1087- }
1088-
1089- public void actionPerformed(ActionEvent e) {
1090- String cmd = e.getActionCommand();
1091- if (cmd.equals("OK") == true) {
1092- if (dungeon != null) {
1093- dungeon.force_end();
1094- }
1095- dialog.dispose();
1096- }
1097- }
1098-
1099-}
1100-//EOF
1101-
1+package CarnageHack;
2+
3+import java.lang.reflect.*;
4+import java.util.ResourceBundle;
5+import java.io.*;
6+import java.awt.*;
7+import java.awt.event.*;
8+import java.security.InvalidAlgorithmParameterException;
9+import java.security.InvalidKeyException;
10+import java.security.NoSuchAlgorithmException;
11+import java.util.Timer;
12+import java.util.logging.Level;
13+import java.util.logging.Logger;
14+import javax.crypto.Cipher;
15+import javax.crypto.CipherOutputStream;
16+import javax.crypto.CipherInputStream;
17+import javax.crypto.NoSuchPaddingException;
18+import javax.crypto.spec.IvParameterSpec;
19+import javax.crypto.spec.SecretKeySpec;
20+
21+/**
22+ * CarnageHack メインパネル
23+ *
24+ * @author fukui
25+ */
26+public final class CarnageHack extends Panel implements ActionListener {
27+
28+ public static final String version = "CarnageHack2 V1.5.0 alpha";
29+ public static final ResourceBundle resource;
30+ public static CHArrayList main_weapon_list;
31+ public static CHArrayList sub_weapon_list;
32+ public static CHArrayList cpu_list;
33+ public static CHArrayList engine_list;
34+ public static CHArrayList armor_list;
35+ public static CHArrayList fueltank_list;
36+ public static CHArrayList option_list;
37+ public static String npcsoftware[];
38+ public static String npchardware[];
39+ public static CHArrayList parts;
40+ public static int update_timer;
41+ public static CHArrayList collected_parts;
42+ public static Point dungeonpos;
43+ public static Point defaultpos;
44+ public static Point chiptablepos;
45+ public static Point softtablepos;
46+ public static Dimension softtablesz;
47+ public static Point hardwarepos;
48+ public static Point stockpos;
49+ private static Frame frame;
50+ private static final String builtin_software[];
51+ private OkeSoftData software;
52+ private OkeSoftData software2;
53+ private int current_edit_soft;
54+ private OkeHardData hardware;
55+ private static final long serialVersionUID = 1;
56+ private static final String cryptPhase = "HageOyaji&Megane";
57+ private static final String vectorPhase = "Manji2Developers";
58+
59+ static {
60+ resource = ResourceBundle.getBundle("CarnageHack/CarnageHack");
61+ parts = new CHArrayList();
62+ collected_parts = new CHArrayList();
63+ main_weapon_list = new CHArrayList();
64+ sub_weapon_list = new CHArrayList();
65+ cpu_list = new CHArrayList();
66+ engine_list = new CHArrayList();
67+ armor_list = new CHArrayList();
68+ fueltank_list = new CHArrayList();
69+ option_list = new CHArrayList();
70+ File f = new File("hige");
71+ npcsoftware = f.list(new OkeSoftFilter(false));
72+ npchardware = f.list(new OkeHardFilter(false));
73+ builtin_software = new String[4];
74+ builtin_software[0] = "soft001.chip";
75+ builtin_software[1] = "soft002.chip";
76+ builtin_software[2] = "soft003.chip";
77+ builtin_software[3] = "soft004.chip";
78+ update_timer = 10;
79+ dungeonpos = new Point();
80+ defaultpos = new Point();
81+ chiptablepos = new Point(328 + 16, 0);
82+ softtablepos = new Point();
83+ softtablesz = new Dimension();
84+ hardwarepos = new Point();
85+ stockpos = new Point(320, 0);
86+ }
87+
88+ /**
89+ * コンストラクタ
90+ */
91+ @SuppressWarnings("LeakingThisInConstructor")
92+ CarnageHack() {
93+ super();
94+ load_master_data();
95+ setLayout(new GridLayout(6, 1));
96+ Button button = new Button(resource.getString("buttonHARDWARE"));
97+ button.addActionListener(this);
98+ button.setActionCommand("HARDWARE");
99+ add(button);
100+ button = new Button(resource.getString("buttonSOFTWARE_A"));
101+ button.addActionListener(this);
102+ button.setActionCommand("SOFTWARE");
103+ add(button);
104+ button = new Button(resource.getString("buttonSOFTWARE_B"));
105+ button.addActionListener(this);
106+ button.setActionCommand("SOFTWARE2");
107+ add(button);
108+ button = new Button(resource.getString("buttonDUNGEON"));
109+ button.addActionListener(this);
110+ button.setActionCommand("DUNGEON");
111+ add(button);
112+ button = new Button(resource.getString("buttonSTOCK"));
113+ button.addActionListener(this);
114+ button.setActionCommand("VIEWPARTS");
115+ add(button);
116+ button = new Button(resource.getString("buttonEXIT"));
117+ button.addActionListener(this);
118+ button.setActionCommand("EXIT");
119+ add(button);
120+ load_setup();
121+ load_data();
122+ }
123+
124+ /**
125+ * 100面体ダイス
126+ *
127+ * @return 0から99の乱数
128+ */
129+ public static int dice100() {
130+ return (int) Math.floor(Math.random() * 100);
131+ }
132+
133+ /**
134+ * ソフトウェアの新規作成
135+ *
136+ * @param obj JARオブジェクト
137+ * @return ソフトウェアデータ
138+ */
139+ public static OkeSoftData makeNewSoft(Object obj) {
140+ int nmax = (npcsoftware == null) ? 0 : Array.getLength(npcsoftware);
141+ if (nmax > 0) {
142+ int n = (int) Math.floor(Math.random() * nmax);
143+ OkeSoftData data = new OkeSoftData();
144+ data.load("hige/" + npcsoftware[n]);
145+ return data;
146+ } else {
147+ int n = (int) Math.floor(Math.random() * builtin_software.length);
148+ OkeSoftData data = new OkeSoftData();
149+ InputStream fis = obj.getClass().
150+ getResourceAsStream("hige/" + builtin_software[n]);
151+ InputStreamReader isr = new InputStreamReader(fis);
152+ BufferedReader fin = new BufferedReader(isr);
153+ data.load(fin);
154+ return data;
155+ }
156+ }
157+
158+ /**
159+ * ハードウェアの新規作成
160+ *
161+ * @return ハードウェアデータ
162+ */
163+ public static OkeHardData makeNewHard() {
164+ int nmax = (npchardware == null) ? 0 : Array.getLength(npchardware);
165+ OkeHardData data = new OkeHardData();
166+ if (nmax == 0 || dice100() > 50) {
167+ //auto build
168+ int target_weight;
169+ data.get_mainweapon().load(auto_select(main_weapon_list));
170+ data.set_main_bullette(
171+ (int) Math.floor(Math.random() * 20) * 10 + 10);
172+ data.get_subweapon().load(auto_select(sub_weapon_list));
173+ data.set_sub_bullette((int) Math.floor(Math.random() * 48) + 1);
174+ data.get_cpu().load(auto_select(cpu_list));
175+ data.get_engine().load(auto_select(engine_list));
176+ data.get_armor().load(auto_select(armor_list));
177+ data.get_fueltank().load(auto_select(fueltank_list));
178+ if (dice100() > 60) {
179+ data.get_option().load(auto_select(option_list));
180+ }
181+ if (dice100() > 60) {
182+ target_weight
183+ = (int) Math.floor(data.get_engine().get_max_weight()
184+ * 1.5);
185+ } else {
186+ target_weight = data.get_engine().get_max_weight();
187+ }
188+ while (target_weight < data.get_total_weight()) {
189+ //over weight
190+ int w1 = data.get_main_bullette();
191+ int w2 = data.get_sub_bullette();
192+ if (w1 == 0 && w2 == 0) {
193+ //can't adjust
194+ break;
195+ }
196+ if (data.get_mainweapon().get_weight() * w1
197+ > data.get_subweapon().get_weight() * w2) {
198+ w1--;
199+ data.set_main_bullette(w1);
200+ } else if (w2 > 0) {
201+ w2--;
202+ data.set_sub_bullette(w2);
203+ } else {
204+ //can't adjust
205+ break;
206+ }
207+ }
208+ } else {
209+ data.load("hige/" + npchardware[(int) Math.floor(Math.random()
210+ * nmax)]);
211+ }
212+ return data;
213+ }
214+
215+ /**
216+ * 指定された配列データから無作為に選択
217+ *
218+ * @param list 配列データ
219+ * @return 選択した要素
220+ */
221+ static String auto_select(CHArrayList list) {
222+ int nmax = list.size();
223+ return (String) list.get((int) Math.floor(Math.random() * nmax));
224+ }
225+
226+ /**
227+ * 指定された名称のデータが配列内にあるかどうかを確認
228+ *
229+ * @param list 配列データ
230+ * @param name 名称
231+ * @return 存在するときにtrue
232+ */
233+ boolean haveparts(CHArrayList list, String name) {
234+ String wk = (String) list.get(0);
235+ String field[] = CHutil.split(wk, ',', 2);
236+ if (field[0].equals(name) == false) {
237+ return (search_parts(name) != -1);
238+ }
239+ return true;
240+ }
241+
242+ /**
243+ * 設定された機体で出撃可能かどうかをチェック
244+ *
245+ * @return 出撃可能な時にtrue
246+ */
247+ boolean check_oke_parts() {
248+ return !(haveparts(main_weapon_list,
249+ hardware.get_mainweapon().get_name()) == false
250+ || haveparts(sub_weapon_list,
251+ hardware.get_subweapon().get_name()) == false
252+ || haveparts(cpu_list, hardware.get_cpu().get_name()) == false
253+ || haveparts(engine_list,
254+ hardware.get_engine().get_name()) == false
255+ || haveparts(armor_list,
256+ hardware.get_armor().get_name()) == false
257+ || haveparts(fueltank_list,
258+ hardware.get_fueltank().get_name()) == false
259+ || haveparts(option_list,
260+ hardware.get_option().get_name()) == false);
261+ }
262+
263+ /**
264+ * 出撃に伴うパーツの在庫更新
265+ *
266+ * @return 出撃成功時にtrue
267+ */
268+ boolean update_parts() {
269+ if (check_oke_parts() == false) {
270+ return false;
271+ }
272+ delete_parts(hardware.get_mainweapon().get_name(),
273+ hardware.get_main_bullette());
274+ delete_parts(hardware.get_subweapon().get_name(),
275+ hardware.get_sub_bullette());
276+ delete_parts(hardware.get_cpu().get_name(), 1);
277+ delete_parts(hardware.get_engine().get_name(), 1);
278+ delete_parts(hardware.get_armor().get_name(), 1);
279+ delete_parts(hardware.get_fueltank().get_name(), 1);
280+ delete_parts(hardware.get_option().get_name(), 1);
281+ return true;
282+ }
283+
284+ /**
285+ * 指定されたOKEがパーツを回収
286+ *
287+ * @param oke OKEデータ
288+ */
289+ void collect_parts(Oke oke) {
290+ int nmax = oke.get_backpack_count();
291+ if (nmax > 0) {
292+ //you get back parts
293+ int i;
294+ for (i = 0; i < nmax; i++) {
295+ String field[] = CHutil.split(oke.get_backpack(i), ':', 3);
296+ String wk;
297+ add_parts(field[0], field[2], Integer.parseInt(field[1]));
298+ wk = field[0] + ":" + field[1] + ":";
299+ field = CHutil.split(field[2], ',', 2);
300+ wk += field[0];
301+ collected_parts.add(wk);
302+ }
303+ collected_parts.sort();
304+ parts.sort();
305+ }
306+ }
307+
308+ /**
309+ * ダンジョンへ出撃
310+ */
311+ boolean dungeon_go(boolean bauto) {
312+ save_data(); //save data now! :D
313+ collected_parts.clear();
314+ //process dungeon...
315+ Dialog dialog = new Dialog(frame, resource.getString(
316+ "titleDUNGEON"), true);
317+ Oke myoke = new Oke(Oke.IFF_FRIEND, 1000, hardware, software,
318+ software2);
319+ OkeDungeon dungeon = new OkeDungeon(dialog, myoke);
320+ CarnageHackDialogEvent chevent
321+ = new CarnageHackDialogEvent(dialog, dungeon);
322+ dungeon.start_timer();
323+ dialog.add(dungeon, BorderLayout.CENTER);
324+ dialog.addWindowListener(chevent);
325+ Button button;
326+ button = new Button(CarnageHack.resource.
327+ getString("buttonDisconnect"));
328+ button.setActionCommand("OK");
329+ button.addActionListener(chevent);
330+ dialog.add(button, BorderLayout.SOUTH);
331+ dialog.pack();
332+ dialog.setLocation(dungeonpos);
333+ dialog.setVisible(true);
334+ dialog.getLocation(dungeonpos);
335+ dungeon.close_status();
336+ //display tombstone or goal screen
337+ Toolkit tk = Toolkit.getDefaultToolkit();
338+ String mesg;
339+ Image icon;
340+ if (dungeon.get_goalin() == true) {
341+ collect_parts(myoke);
342+ save_data(); //save data again! :D
343+ mesg = resource.getString("RTBmessage");
344+ if (dungeon.is_havehige() == true) {
345+ mesg += resource.getString("SuccessMessage");
346+ icon = tk.getImage(getClass().
347+ getResource("icon/success.png"));
348+ } else {
349+ mesg += resource.getString("FailMessage");
350+ icon = tk.getImage(getClass().
351+ getResource("icon/failed.png"));
352+ }
353+ } else {
354+ if (myoke.isdead() == true) {
355+ mesg = resource.getString("DestroyMessage");
356+ switch (myoke.get_reason()) {
357+ case Oke.DAMAGE_DESTRUCT:
358+ if (myoke.get_attacker() == myoke) {
359+ mesg
360+ += resource.getString(
361+ "ReasonSelfDestruct");
362+ } else {
363+ mesg += resource.getString(
364+ "ReasonDestruct");
365+ }
366+ break;
367+ case Oke.DAMAGE_HEAT:
368+ mesg += resource.getString("ReasonHeat");
369+ break;
370+ case Oke.DAMAGE_FIGHT:
371+ mesg += resource.getString("ReasonFight");
372+ break;
373+ case Oke.DAMAGE_ASSALUT:
374+ mesg += resource.getString("ReasonAssalut");
375+ break;
376+ case Oke.DAMAGE_LASER:
377+ mesg += resource.getString("ReasonLaser");
378+ break;
379+ case Oke.DAMAGE_SHOTGUN:
380+ mesg += resource.getString("ReasonShotgun");
381+ break;
382+ case Oke.DAMAGE_MISSILE:
383+ mesg += resource.getString("ReasonMissile");
384+ break;
385+ case Oke.DAMAGE_ROCKET:
386+ mesg += resource.getString("ReasonRocket");
387+ break;
388+ default:
389+ mesg += resource.getString("ReasonNone");
390+ break;
391+ }
392+ mesg += resource.getString("DestroyMessage2")
393+ + (myoke.get_floor() + 1)
394+ + resource.getString("DestroyMessage3");
395+ } else {
396+ mesg = resource.getString("QuitMessage");
397+ }
398+ icon = tk.getImage(getClass().
399+ getResource("icon/tombstone.png"));
400+ }
401+ mesg += resource.getString("OkeScoreMessage1")
402+ + myoke.get_destroycount()
403+ + resource.getString("OkeScoreMessage2");
404+ if (collected_parts.size() > 0) {
405+ mesg += resource.getString("OkeScoreMessage3")
406+ + collected_parts.size()
407+ + resource.getString("OkeScoreMessage4");
408+ }
409+ mesg += resource.getString("MaximumFloorMessage")
410+ + dungeon.get_maximum_floor()
411+ + resource.getString("MaximumFloorMessage2");
412+ //ユーザーがボタンを押したら自動実行を解除
413+ bauto = CHutil.MessageBox(mesg, resource.getString("ReportTitle"),
414+ icon, false, 10000) != true;
415+ if (collected_parts.size() > 0) {
416+ Timer timer = null;
417+ CHtimerAutoClose ttask = null;
418+ Dialog clist
419+ = new Dialog(frame, resource.getString(
420+ "titlePARTS_LIST"), true);
421+ List list = new List(20);
422+ CHmessageboxEvent msgevent = new CHmessageboxEvent(clist);
423+ int i;
424+ for (i = 0; i < collected_parts.size(); i++) {
425+ list.add((String) collected_parts.get(i));
426+ }
427+ clist.add(list, BorderLayout.CENTER);
428+ clist.addWindowListener(msgevent);
429+ button = new Button(
430+ CarnageHack.resource.getString("buttonOK"));
431+ button.setActionCommand("OK");
432+ button.addActionListener(msgevent);
433+ clist.add(button, BorderLayout.SOUTH);
434+ clist.setSize(320, 400);
435+ clist.setLocationRelativeTo(frame);
436+ if (bauto == true) {
437+ timer = new Timer();
438+ ttask = new CHtimerAutoClose(clist);
439+ ttask.set_button(button, button.getLabel());
440+ ttask.set_timeout(5000);
441+ timer.schedule(ttask, 0, 1000);
442+ }
443+ clist.setVisible(true);
444+ if (timer != null) {
445+ timer.cancel();
446+ }
447+ if (ttask != null) {
448+ ttask.cancel();
449+ }
450+ }
451+ return bauto;
452+ }
453+
454+ private void edit_software(int nsoft, String title, OkeSoftData sd) {
455+ //build up software
456+ Dialog dialog = new Dialog(frame, title, false);
457+ OkeSoftPanel softpanel
458+ = new OkeSoftPanel(this, frame, dialog, sd);
459+ ScrollPane scrpane = new ScrollPane(ScrollPane.SCROLLBARS_ALWAYS);
460+ current_edit_soft = nsoft;
461+ scrpane.add(softpanel);
462+ scrpane.setSize(328, 328);
463+ dialog.add(scrpane);
464+ dialog.pack();
465+ dialog.setLocation(softtablepos);
466+ if (softtablesz.width != 0 && softtablesz.height != 0) {
467+ dialog.setSize(softtablesz);
468+ }
469+ frame.setEnabled(false);
470+ dialog.setVisible(true);
471+ }
472+
473+ @Override
474+ public void actionPerformed(ActionEvent e) {
475+ String cmd = e.getActionCommand();
476+ if (cmd.equals("SOFTWARE") == true) {
477+ //build up software
478+ edit_software(1, resource.getString("buttonSOFTWARE_A"), software);
479+ } else if (cmd.equals("SOFTWARE2") == true) {
480+ //build up software 2
481+ edit_software(2, resource.getString("buttonSOFTWARE_B"), software2);
482+ } else if (cmd.equals("HARDWARE") == true) {
483+ //build up hardware
484+ Dialog dialog = new Dialog(frame, resource.getString(
485+ "buttonHARDWARE"), true);
486+ CHmessageboxEvent msgevent = new CHmessageboxEvent(dialog);
487+ OkeHardPanel hardpanel = new OkeHardPanel(hardware);
488+ hardware = hardpanel.get_hardware();
489+ dialog.add(hardpanel, BorderLayout.CENTER);
490+ dialog.addWindowListener(msgevent);
491+ Button button;
492+ button = new Button(CarnageHack.resource.getString("buttonOK"));
493+ button.setActionCommand("OK");
494+ button.addActionListener(msgevent);
495+ dialog.add(button, BorderLayout.SOUTH);
496+ dialog.pack();
497+ dialog.setLocation(hardwarepos);
498+ dialog.setVisible(true);
499+ dialog.getLocation(hardwarepos);
500+ } else if (cmd.equals("DUNGEON") == true) {
501+ if (software != null && software.get(0, 0) != null && hardware
502+ != null) {
503+ //go to dungeon!
504+ boolean bauto = false;
505+ do {
506+ if (check_oke_parts() == false) { //check used parts
507+ //don't have parts
508+ CHutil.MessageBox(resource.getString("noParts"),
509+ resource.getString("noPartsTitle"),
510+ null, false);
511+ return;
512+ }
513+ if (bauto == false) {
514+ if (CHutil.MessageBox(resource.getString("confirmGoTo"),
515+ resource.getString("confirmGoToTitle"),
516+ null, true) == false) {
517+ return;
518+ }
519+ bauto = true;
520+ } else {
521+ if (CHutil.MessageBox(
522+ resource.getString("confirmAutoGo"),
523+ resource.getString("confirmGoToTitle"),
524+ null, false, 5000) == true) {
525+ return;
526+ }
527+ }
528+ if (update_parts() == false) {
529+ //huh?
530+ CHutil.MessageBox(resource.getString("noParts"),
531+ resource.getString("noPartsTitle"),
532+ null, false);
533+ return;
534+ }
535+ bauto = dungeon_go(bauto);
536+ } while (bauto);
537+ } else {
538+ CHutil.MessageBox(resource.getString("ngGoTo"),
539+ resource.getString("ngGoToTitle"),
540+ null, false);
541+ }
542+ } else if (cmd.equals("VIEWPARTS") == true) {
543+ //view current parts
544+ Dialog dialog = new Dialog(frame, resource.getString("titlePARTS"),
545+ true);
546+ CHmessageboxEvent msgevent = new CHmessageboxEvent(dialog);
547+ List list = new List(20);
548+ int i;
549+ for (i = 0; i < parts.size(); i++) {
550+ String wk = (String) parts.get(i);
551+ String field[] = CHutil.split(wk, ':', 3);
552+ wk = field[0] + ":" + field[1] + ":";
553+ field = CHutil.split(field[2], ',', 2);
554+ wk += field[0];
555+ list.add(wk);
556+ }
557+ dialog.add(list, BorderLayout.CENTER);
558+ dialog.addWindowListener(msgevent);
559+ Button button;
560+ button = new Button(CarnageHack.resource.getString("buttonOK"));
561+ button.setActionCommand("OK");
562+ button.addActionListener(msgevent);
563+ dialog.add(button, BorderLayout.SOUTH);
564+ dialog.setLocation(stockpos);
565+ dialog.setSize(320, 400);
566+ dialog.setVisible(true);
567+ dialog.getLocation(stockpos);
568+ } else if (cmd.equals("EXIT") == true) {
569+ //終了
570+ save_setup();
571+ System.exit(0);
572+ }
573+ }
574+
575+ /**
576+ * パーツ検索
577+ *
578+ * @param name 名称
579+ * @return 発見したインデックス。 見つからないときに-1
580+ */
581+ public static int search_parts(String name) {
582+ int i;
583+ int nmax = parts.size();
584+ for (i = 0; i < nmax; i++) {
585+ String wk = (String) parts.get(i);
586+ String field[] = CHutil.split(wk, ':', 3);
587+ wk = field[2];
588+ field = CHutil.split(wk, ',', 2);
589+ if (field[0].equals(name) == true) {
590+ return i;
591+ }
592+ }
593+ return -1;
594+ }
595+
596+ /**
597+ * 指定した番号のパーツを削除
598+ *
599+ * @param name 名称
600+ * @param n インデックス
601+ */
602+ public static void delete_parts(String name, int n) {
603+ int idx = search_parts(name);
604+ if (idx >= 0) {
605+ String wk = (String) parts.get(idx);
606+ String field[] = CHutil.split(wk, ':', 3);
607+ int nwk = Integer.parseInt(field[1]);
608+ nwk -= n;
609+ if (nwk <= 0) {
610+ parts.remove(idx);
611+ } else {
612+ parts.set(idx, field[0] + ":" + nwk + ":" + field[2]);
613+ }
614+ }
615+ }
616+
617+ /**
618+ * パーツを追加
619+ *
620+ * @param t パーツタイプ
621+ * @param s パーツデータ
622+ * @param n パーツ数
623+ */
624+ public static void add_parts(String t, String s, int n) {
625+ int i;
626+ String field[];
627+ String wk;
628+ String name;
629+ field = CHutil.split(s, ',', 2);
630+ name = field[0];
631+ i = search_parts(name);
632+ if (i >= 0) {
633+ wk = (String) parts.get(i);
634+ field = CHutil.split(wk, ':', 3);
635+ int nwk = Integer.parseInt(field[1]) + n;
636+ parts.set(i, field[0] + ":" + nwk + ":" + field[2]);
637+ } else {
638+ parts.add(t + ":" + n + ":" + s);
639+ }
640+ }
641+
642+ /**
643+ * 指定されたパーツが初期パーツかどうかを確認
644+ *
645+ * @param t パーツタイプ
646+ * @param s パーツデータ
647+ * @return
648+ */
649+ public static boolean isdefaultparts(String t, String s) {
650+ if (t.equals("M") == true) {
651+ return s.equals((String) main_weapon_list.get(0));
652+ } else if (t.equals("S") == true) {
653+ return s.equals((String) sub_weapon_list.get(0));
654+ } else if (t.equals("C") == true) {
655+ return s.equals((String) cpu_list.get(0));
656+ } else if (t.equals("E") == true) {
657+ return s.equals((String) engine_list.get(0));
658+ } else if (t.equals("A") == true) {
659+ return s.equals((String) armor_list.get(0));
660+ } else if (t.equals("F") == true) {
661+ return s.equals((String) fueltank_list.get(0));
662+ } else if (t.equals("O") == true) {
663+ return s.equals((String) option_list.get(0));
664+ }
665+ return false;
666+ }
667+
668+ /**
669+ * パーツを生成する
670+ *
671+ * @return 生成したパーツ(タイプ:名称:数量)
672+ */
673+ static public String generate_parts() {
674+ String partsdata = new String();
675+ int n = (int) Math.floor(Math.random() * 7);
676+ CHArrayList list;
677+ String t;
678+ int ncount = 1;
679+ switch (n) {
680+ case 0:
681+ list = CarnageHack.main_weapon_list;
682+ ncount = ((int) Math.floor(Math.random() * 10) + 1) * 10;
683+ t = "M";
684+ break;
685+ case 1:
686+ list = CarnageHack.sub_weapon_list;
687+ ncount = (int) Math.floor(Math.random() * 24) + 1;
688+ t = "S";
689+ break;
690+ case 2:
691+ list = CarnageHack.cpu_list;
692+ t = "C";
693+ break;
694+ case 3:
695+ list = CarnageHack.engine_list;
696+ t = "E";
697+ break;
698+ case 4:
699+ list = CarnageHack.armor_list;
700+ t = "A";
701+ break;
702+ case 5:
703+ list = CarnageHack.fueltank_list;
704+ t = "F";
705+ break;
706+ case 6:
707+ list = CarnageHack.option_list;
708+ t = "O";
709+ break;
710+ default:
711+ list = null;
712+ t = null;
713+ break;
714+ }
715+ if (list != null) {
716+ int m = list.size() - 1;
717+ partsdata = t + ":";
718+ partsdata += (String) list.get((int) Math.floor(Math.random() * m)
719+ + 1) + ":";
720+ partsdata += ncount;
721+ }
722+ return partsdata;
723+ }
724+
725+ /**
726+ * パーツマスタデータの読み込み
727+ */
728+ void load_master_data() {
729+ try {
730+ InputStream fis = getClass().
731+ getResourceAsStream(resource.getString("namePartsData"));
732+ InputStreamReader isr = new InputStreamReader(fis,
733+ resource.getString("codingPartsData"));
734+ try (BufferedReader r = new BufferedReader(isr)) {
735+ String wkline;
736+ while ((wkline = r.readLine()) != null) {
737+ String field[] = CHutil.split(wkline, ':', 2);
738+ if (field[0].equals("M") == true) {
739+ //main weapon
740+ main_weapon_list.add(field[1]);
741+ } else if (field[0].equals("S") == true) {
742+ //sub weapon
743+ sub_weapon_list.add(field[1]);
744+ } else if (field[0].equals("C") == true) {
745+ //cpu
746+ cpu_list.add(field[1]);
747+ } else if (field[0].equals("E") == true) {
748+ //engine
749+ engine_list.add(field[1]);
750+ } else if (field[0].equals("A") == true) {
751+ //armor
752+ armor_list.add(field[1]);
753+ } else if (field[0].equals("F") == true) {
754+ //fuel tank
755+ fueltank_list.add(field[1]);
756+ } else if (field[0].equals("O") == true) {
757+ //option
758+ option_list.add(field[1]);
759+ }
760+ }
761+ }
762+ } catch (Exception e) {
763+ CHutil.MessageBox(resource.getString("loadErr"),
764+ resource.getString("loadErrTitle"),
765+ null, false);
766+ }
767+ }
768+
769+ /**
770+ * 初期所持パーツの配布
771+ */
772+ static void initialize_inventory() {
773+ int i;
774+ String[] field;
775+ for (i = 0; i < 10; i++) {
776+ field = CHutil.split(generate_parts(), ':', 3);
777+ add_parts(field[0], field[1], Integer.parseInt(field[2], 10));
778+ }
779+ }
780+
781+ /**
782+ * 暗号化データの取得
783+ *
784+ * @param opmode 暗号化モード
785+ * @return 初期化済み暗号化オブジェクト
786+ */
787+ static public Cipher generateCipher(int opmode) {
788+ try {
789+ SecretKeySpec skey
790+ = new SecretKeySpec(cryptPhase.getBytes("UTF-8"), "AES");
791+ IvParameterSpec iv
792+ = new IvParameterSpec(vectorPhase.getBytes("UTF-8"));
793+ Cipher ci = Cipher.getInstance("AES/CBC/PKCS5PADDING");
794+ ci.init(opmode, skey, iv);
795+ return ci;
796+ } catch (UnsupportedEncodingException | NoSuchAlgorithmException |
797+ NoSuchPaddingException | InvalidKeyException |
798+ InvalidAlgorithmParameterException ex) {
799+ Logger.getLogger(CarnageHack.class.getName()).
800+ log(Level.SEVERE, null, ex);
801+ }
802+ return null;
803+ }
804+
805+ /**
806+ * 在庫パーツデータの読み込み
807+ */
808+ static void load_data() {
809+ boolean bnewUser = false;
810+ try {
811+ Cipher ci = generateCipher(Cipher.DECRYPT_MODE);
812+ String wkdir = System.getProperty("user.home", ".");
813+ CipherInputStream is = new CipherInputStream(
814+ new FileInputStream(wkdir + "/CarnageHack2.save"), ci);
815+ try (BufferedReader r = new BufferedReader(new InputStreamReader(is))) {
816+ String wkline;
817+ parts.clear();
818+ while ((wkline = r.readLine()) != null) {
819+ parts.add(wkline);
820+ }
821+ parts.sort();
822+ }
823+ } catch (IOException e) {
824+ CHutil.MessageBox(resource.getString("newUser"),
825+ resource.getString("newUserTitle"),
826+ null, false);
827+ bnewUser = true;
828+ }
829+ if (bnewUser == true) {
830+ //新規ユーザーにはいくつかパーツを配布
831+ initialize_inventory();
832+ }
833+ }
834+
835+ /**
836+ * 在庫パーツデータの保存
837+ */
838+ static void save_data() {
839+ try {
840+ Cipher ci = generateCipher(Cipher.ENCRYPT_MODE);
841+ String wkdir = System.getProperty("user.home", ".");
842+ try (CipherOutputStream os = new CipherOutputStream(
843+ new FileOutputStream(wkdir
844+ + "/CarnageHack2.save"), ci);
845+ BufferedWriter w = new BufferedWriter(
846+ new OutputStreamWriter(os))) {
847+ int i;
848+ for (i = 0; i < parts.size(); i++) {
849+ String wk = (String) parts.get(i);
850+ w.write(wk, 0, wk.length());
851+ w.newLine();
852+ }
853+ }
854+ } catch (IOException e) {
855+ CHutil.MessageBox(resource.getString("saveErr"),
856+ resource.getString("saveErrTitle"),
857+ null, false);
858+ }
859+ }
860+
861+ /**
862+ * 表示更新間隔を取得
863+ *
864+ * @return 表示更新間隔
865+ */
866+ static int get_update_timer() {
867+ return update_timer;
868+ }
869+
870+ /**
871+ * 表示更新間隔を設定
872+ *
873+ * @param n 表示更新間隔
874+ */
875+ static void set_update_timer(int n) {
876+ update_timer = n;
877+ }
878+
879+ /**
880+ * 設定値の読み込み
881+ */
882+ static void load_setup() {
883+ try {
884+ String wkdir = System.getProperty("user.home", ".");
885+ try (BufferedReader r = new BufferedReader(new FileReader(wkdir
886+ + "/CarnageHack2.setup"))) {
887+ String wkline;
888+ while ((wkline = r.readLine()) != null) {
889+ String field[] = CHutil.split(wkline, ',');
890+ if (field[0].equals("UPDATE") == true) {
891+ update_timer = Integer.parseInt(field[1]);
892+ if (update_timer < 1) {
893+ update_timer = 1;
894+ }
895+ } else if (field[0].equals("DUNGEONVIEW") == true) {
896+ int w = Integer.parseInt(field[1]);
897+ int h = Integer.parseInt(field[2]);
898+ if (w < 100) {
899+ w = 100;
900+ }
901+ if (h < 100) {
902+ h = 100;
903+ }
904+ OkeDungeon.Width = w;
905+ OkeDungeon.Height = h;
906+ } else if (field[0].endsWith("DUNGEONPOS") == true) {
907+ int x = Integer.parseInt(field[1]);
908+ int y = Integer.parseInt(field[2]);
909+ dungeonpos.setLocation(x, y);
910+ } else if (field[0].endsWith("MAINWINDOW") == true) {
911+ int x = Integer.parseInt(field[1]);
912+ int y = Integer.parseInt(field[2]);
913+ defaultpos.setLocation(x, y);
914+ } else if (field[0].endsWith("SOFTTABLE") == true) {
915+ int x = Integer.parseInt(field[1]);
916+ int y = Integer.parseInt(field[2]);
917+ softtablepos.setLocation(x, y);
918+ } else if (field[0].endsWith("CHIPTABLE") == true) {
919+ int x = Integer.parseInt(field[1]);
920+ int y = Integer.parseInt(field[2]);
921+ chiptablepos.setLocation(x, y);
922+ } else if (field[0].endsWith("HARDWARE") == true) {
923+ int x = Integer.parseInt(field[1]);
924+ int y = Integer.parseInt(field[2]);
925+ hardwarepos.setLocation(x, y);
926+ } else if (field[0].endsWith("STOCK") == true) {
927+ int x = Integer.parseInt(field[1]);
928+ int y = Integer.parseInt(field[2]);
929+ stockpos.setLocation(x, y);
930+ } else if (field[0].endsWith("SOFTWAREDIR") == true) {
931+ OkeSoftPanel.setDataDir(field[1]);
932+ } else if (field[0].endsWith("HARDWAREDIR") == true) {
933+ OkeHardPanel.setDataDir(field[1]);
934+ }
935+ }
936+ }
937+ } catch (IOException | NumberFormatException e) {
938+ }
939+ }
940+
941+ /**
942+ * 設定値の保存
943+ */
944+ static void save_setup() {
945+ try {
946+ Point wkpos;
947+ String wkdir = System.getProperty("user.home", ".");
948+ try (BufferedWriter w = new BufferedWriter(new FileWriter(wkdir
949+ + "/CarnageHack2.setup"))) {
950+ String wkline;
951+ wkline = "UPDATE," + update_timer;
952+ w.write(wkline, 0, wkline.length());
953+ w.newLine();
954+ wkline = "DUNGEONVIEW," + OkeDungeon.Width + ","
955+ + OkeDungeon.Height;
956+ w.write(wkline, 0, wkline.length());
957+ w.newLine();
958+ wkline = "DUNGEONPOS," + dungeonpos.x + "," + dungeonpos.y;
959+ w.write(wkline, 0, wkline.length());
960+ w.newLine();
961+ wkpos = frame.getLocation();
962+ wkline = "MAINWINDOW," + wkpos.x + "," + wkpos.y;
963+ w.write(wkline, 0, wkline.length());
964+ w.newLine();
965+ wkline = "SOFTTABLE," + softtablepos.x + "," + softtablepos.y;
966+ w.write(wkline, 0, wkline.length());
967+ w.newLine();
968+ wkline = "CHIPTABLE," + chiptablepos.x + "," + chiptablepos.y;
969+ w.write(wkline, 0, wkline.length());
970+ w.newLine();
971+ wkline = "HARDWARE," + hardwarepos.x + "," + hardwarepos.y;
972+ w.write(wkline, 0, wkline.length());
973+ w.newLine();
974+ wkline = "STOCK," + stockpos.x + "," + stockpos.y;
975+ w.write(wkline, 0, wkline.length());
976+ w.newLine();
977+ wkline = "SOFTWAREDIR," + OkeSoftPanel.getDataDir();
978+ w.write(wkline, 0, wkline.length());
979+ w.newLine();
980+ wkline = "HARDWAREDIR," + OkeHardPanel.getDataDir();
981+ w.write(wkline, 0, wkline.length());
982+ w.newLine();
983+ }
984+ } catch (Exception e) {
985+ }
986+ }
987+
988+ /**
989+ * 出撃用ソフトウェアを設定
990+ *
991+ * @param soft ソフトウェアデータ
992+ */
993+ public void set_software(OkeSoftData soft) {
994+ if (current_edit_soft == 1) {
995+ software = soft;
996+ } else {
997+ software2 = soft;
998+ }
999+ }
1000+
1001+ /**
1002+ * メイン
1003+ *
1004+ * @param args
1005+ */
1006+ public static void main(String[] args) {
1007+ System.out.println(version + " Copyright by T.Fukui 2007-2016");
1008+ frame = new Frame(version);
1009+ CHutil.SplashBox(version);
1010+ frame.add(new CarnageHack());
1011+ frame.addWindowListener(new CarnageHackWindowEvent());
1012+ frame.setSize(320, 200);
1013+ frame.setLocation(defaultpos);
1014+ frame.setVisible(true);
1015+ }
1016+
1017+ /**
1018+ * フレームウィンドウ取得
1019+ *
1020+ * @return フレームウィンドウ
1021+ */
1022+ public static Frame getFrame() {
1023+ return frame;
1024+ }
1025+}
1026+
1027+/**
1028+ * ウィンドウイベントハンドラ
1029+ *
1030+ * @author fukui
1031+ */
1032+class CarnageHackWindowEvent extends WindowAdapter {
1033+
1034+ @Override
1035+ public void windowClosing(WindowEvent e) {
1036+ CarnageHack.save_setup();
1037+ System.exit(0);
1038+ }
1039+}
1040+
1041+/**
1042+ * ダンジョンウィンドウイベントハンドラ
1043+ *
1044+ * @author fukui
1045+ */
1046+class CarnageHackDialogEvent extends WindowAdapter implements ActionListener {
1047+
1048+ Dialog dialog;
1049+ OkeDungeon dungeon;
1050+
1051+ /**
1052+ * コンストラクタ
1053+ *
1054+ * @param d ダンジョンデータ
1055+ */
1056+ CarnageHackDialogEvent(Dialog dlg, OkeDungeon d) {
1057+ super();
1058+ dialog = dlg;
1059+ dungeon = d;
1060+ }
1061+
1062+ @Override
1063+ public void windowClosing(WindowEvent e) {
1064+ if (dungeon != null) {
1065+ dungeon.force_end();
1066+ }
1067+ dialog.dispose();
1068+ }
1069+
1070+ @Override
1071+ public void actionPerformed(ActionEvent e) {
1072+ String cmd = e.getActionCommand();
1073+ if (cmd.equals("OK") == true) {
1074+ if (dungeon != null) {
1075+ dungeon.force_end();
1076+ }
1077+ dialog.dispose();
1078+ }
1079+ }
1080+
1081+}
1082+//EOF
1083+