Skip to content

Commit 0e44b9b

Browse files
committed
Merge remote-tracking branch 'origin/master'
# Conflicts: # src/view/WindowChanger.java # src/view/fxmlControllers/MainMenuController.java # src/view/fxmls/LoadedScenes.java
2 parents c9cdbac + a6309cc commit 0e44b9b

36 files changed

+795
-343
lines changed

src/controller/Main.java

+11-10
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,17 @@ public void start(Stage primaryStage) {
3232

3333
new LoadWindow().main();
3434

35-
WindowChanger.instance.setNewScene(LoadedScenes.registerMenu);
36-
// {//arena
37-
// Account account = new Account("test", "test");
38-
// account.getCollection().setMainDeck(Deck.getAllDecks().get("level1"));
39-
// Game game = Level.getAvailableLevels().get("1").getLevelGame(account);
40-
// ArenaController.ac.init(game);
41-
// game.initialiseGameFields();
42-
//
43-
// WindowChanger.instance.setNewScene(LoadedScenes.arena);
44-
// }
35+
// WindowChanger.instance.setNewScene(LoadedScenes.registerMenu);
36+
37+
{//arena
38+
Account account = new Account("test", "test");
39+
account.getCollection().setMainDeck(Deck.getAllDecks().get("level1"));
40+
Game game = Level.getAvailableLevels().get("1").getLevelGame(account);
41+
ArenaController.ac.init(game);
42+
game.initialiseGameFields();
43+
44+
WindowChanger.instance.setNewScene(LoadedScenes.arena);
45+
}
4546

4647
mainStage.show();
4748
}

src/controller/window/ShopWindow.java

+151-151
Original file line numberDiff line numberDiff line change
@@ -1,151 +1,151 @@
1-
//package controller.window;
2-
//
3-
//import model.Collection;
4-
//import model.Shop;
5-
//import model.cards.Card;
6-
//import model.cards.Hero;
7-
//import model.cards.Spell;
8-
//import model.effects.Effect;
9-
//import model.effects.Melee;
10-
//import model.effects.Ranged;
11-
//import view.Message;
12-
//
13-
//import java.util.ArrayList;
14-
//
15-
//import static view.Request.getNextRequest;
16-
//
17-
//public class ShopWindow extends Window {
18-
//
19-
// public void main() {
20-
// tag1:
21-
// while (true) {
22-
// Message.showShopHelp();
23-
// String input = getNextRequest();
24-
// if (!input.matches("\\d+")) {
25-
// Message.invalidInput();
26-
// continue;
27-
// }
28-
// int indexOfSelectedSubMenu = Integer.parseInt(input);
29-
// switch (indexOfSelectedSubMenu) {
30-
// case 1:
31-
// handleShowInfoOfCards(Shop.getShop().getCardIDs(), 2);
32-
// continue;
33-
// case 2:
34-
// handleShowInfoOfCards(Collection.getCollection().getCardIDs(), 1);
35-
// continue;
36-
// case 3:
37-
// Message.InterCardName();
38-
// String cardName = getNextRequest();
39-
// Shop.getShop().searchInShopCards(cardName);
40-
// continue;
41-
// case 4:
42-
// Message.InterCardName();
43-
// cardName = getNextRequest();
44-
// Shop.getShop().searchInCollectionCards(cardName);
45-
// continue;
46-
// case 5:
47-
// Message.InterCardName();
48-
// cardName = getNextRequest();
49-
// Shop.getShop().buy(cardName);
50-
// continue;
51-
// case 6:
52-
// Message.interCardName();
53-
// cardName = getNextRequest();
54-
// Shop.getShop().sell(cardName);
55-
// continue;
56-
// case 0:
57-
// this.closeWindow();
58-
// break tag1;
59-
// default:
60-
// Message.invalidInput();
61-
// }
62-
// }
63-
// }
64-
//
65-
// //kind==1 price for sell is shown //kind==2 price for buy is shown //kind==3 price isn't shown
66-
// public static void handleShowInfoOfCards(ArrayList<Integer> repository, int kind) {
67-
// if (repository.size() == 0) {
68-
// Message.noCardInThisRepository();
69-
// return;
70-
// }
71-
// ArrayList<Card> heroes = new ArrayList<>();
72-
// ArrayList<Card> items = new ArrayList<>();
73-
// ArrayList<Card> otherCards = new ArrayList<>();
74-
// for (int cardID : repository) {
75-
// Card card = Card.getAllCards().get(cardID);
76-
// if (card instanceof Hero) {
77-
// heroes.add(card);
78-
// } else if (Spell.checkIsItem(card)) {
79-
// items.add(card);
80-
// } else {
81-
// otherCards.add(card);
82-
// }
83-
// }
84-
// showInfoOfHeroes(heroes, kind);
85-
// showInfoOfItems(items, kind);
86-
// showInfoOfOtherCards(otherCards, kind);
87-
// }
88-
//
89-
// public static void showInfoOfHeroes(ArrayList<Card> heroes, int kind) {
90-
// Message.printSomeThing("_Hero:");
91-
// for (int i = 0; i < heroes.size(); i++) {
92-
// int template = 0;
93-
// String kindOfAttackArea = "Hybrid"; // byDefault
94-
// for (Effect effect : heroes.get(i).getEffects()) {
95-
// if (effect instanceof Melee) {
96-
// template += 1;
97-
// }
98-
// if (effect instanceof Ranged) {
99-
// template += 2;
100-
// }
101-
// }
102-
// if (template == 1) kindOfAttackArea = "Melee";
103-
// if (template == 2) kindOfAttackArea = "Ranged";
104-
//
105-
// if (kind == 1) {
106-
// Message.showInfoOfHeroPlusPrice((Hero) heroes.get(i), i + 1, kindOfAttackArea, "Sell");
107-
// }
108-
// if (kind == 2) {
109-
// Message.showInfoOfHeroPlusPrice((Hero) heroes.get(i), i + 1, kindOfAttackArea, "Buy");
110-
// }
111-
// if (kind == 3) {
112-
// Message.showInfoOfHeroMinusPrice((Hero) heroes.get(i), i + 1, kindOfAttackArea);
113-
// }
114-
// }
115-
// }
116-
//
117-
// public static void showInfoOfItems(ArrayList<Card> items, int kind) {
118-
// Message.printSomeThing("_Item:");
119-
// for (int i = 0, k = 1; i < items.size(); i++) {
120-
// if (items.get(i).getPrice() == 0) continue;
121-
// if (kind == 1) {
122-
// Message.showInfoOfItemPlusPrice((Spell) items.get(i), k, "Sell");
123-
// }
124-
// if (kind == 2) {
125-
// Message.showInfoOfItemPlusPrice((Spell) items.get(i), k, "Buy");
126-
// }
127-
// if (kind == 3) {
128-
// Message.showInfoOfItemMinusPrice((Spell) items.get(i), k);
129-
// }
130-
// k++;
131-
// }
132-
// }
133-
//
134-
// public static void showInfoOfOtherCards(ArrayList<Card> others, int kind) {
135-
// Message.printSomeThing("_Cards:");
136-
// for (int i = 0; i < others.size(); i++) {
137-
// String type;
138-
// if (others.get(i) instanceof Spell) type = "Spell";
139-
// else type = "Minion";
140-
// if (kind == 1) {
141-
// Message.showInfoOfCardPlusPrice(others.get(i), i + 1, type, "Sell");
142-
// }
143-
// if (kind == 2) {
144-
// Message.showInfoOfCardPlusPrice(others.get(i), i + 1, type, "Buy");
145-
// }
146-
// if (kind == 3) {
147-
// Message.showInfoOfCardMinusPrice(others.get(i), i + 1, type);
148-
// }
149-
// }
150-
// }
151-
//}
1+
package controller.window;
2+
3+
import model.Collection;
4+
import model.Shop;
5+
import model.cards.Card;
6+
import model.cards.Hero;
7+
import model.cards.Spell;
8+
import model.effects.Effect;
9+
import model.effects.Melee;
10+
import model.effects.Ranged;
11+
import view.Message;
12+
13+
import java.util.ArrayList;
14+
15+
import static view.Request.getNextRequest;
16+
17+
public class ShopWindow extends Window {
18+
19+
public void main() {
20+
tag1:
21+
while (true) {
22+
Message.showShopHelp();
23+
String input = getNextRequest();
24+
if (!input.matches("\\d+")) {
25+
Message.invalidInput();
26+
continue;
27+
}
28+
int indexOfSelectedSubMenu = Integer.parseInt(input);
29+
switch (indexOfSelectedSubMenu) {
30+
case 1:
31+
handleShowInfoOfCards(Shop.getShop().getCardIDs(), 2);
32+
continue;
33+
case 2:
34+
handleShowInfoOfCards(Collection.getCollection().getCardIDs(), 1);
35+
continue;
36+
case 3:
37+
Message.InterCardName();
38+
String cardName = getNextRequest();
39+
Shop.getShop().searchInShopCards(cardName);
40+
continue;
41+
case 4:
42+
Message.InterCardName();
43+
cardName = getNextRequest();
44+
Shop.getShop().searchInCollectionCards(cardName);
45+
continue;
46+
case 5:
47+
Message.InterCardName();
48+
cardName = getNextRequest();
49+
Shop.getShop().buy(cardName);
50+
continue;
51+
case 6:
52+
Message.interCardName();
53+
cardName = getNextRequest();
54+
Shop.getShop().sell(cardName);
55+
continue;
56+
case 0:
57+
this.closeWindow();
58+
break tag1;
59+
default:
60+
Message.invalidInput();
61+
}
62+
}
63+
}
64+
65+
//kind==1 price for sell is shown //kind==2 price for buy is shown //kind==3 price isn't shown
66+
public static void handleShowInfoOfCards(ArrayList<Integer> repository, int kind) {
67+
if (repository.size() == 0) {
68+
Message.noCardInThisRepository();
69+
return;
70+
}
71+
ArrayList<Card> heroes = new ArrayList<>();
72+
ArrayList<Card> items = new ArrayList<>();
73+
ArrayList<Card> otherCards = new ArrayList<>();
74+
for (int cardID : repository) {
75+
Card card = Card.getAllCards().get(cardID);
76+
if (card instanceof Hero) {
77+
heroes.add(card);
78+
} else if (Spell.checkIsItem(card)) {
79+
items.add(card);
80+
} else {
81+
otherCards.add(card);
82+
}
83+
}
84+
showInfoOfHeroes(heroes, kind);
85+
showInfoOfItems(items, kind);
86+
showInfoOfOtherCards(otherCards, kind);
87+
}
88+
89+
public static void showInfoOfHeroes(ArrayList<Card> heroes, int kind) {
90+
Message.printSomeThing("_Hero:");
91+
for (int i = 0; i < heroes.size(); i++) {
92+
int template = 0;
93+
String kindOfAttackArea = "Hybrid"; // byDefault
94+
for (Effect effect : heroes.get(i).getEffects()) {
95+
if (effect instanceof Melee) {
96+
template += 1;
97+
}
98+
if (effect instanceof Ranged) {
99+
template += 2;
100+
}
101+
}
102+
if (template == 1) kindOfAttackArea = "Melee";
103+
if (template == 2) kindOfAttackArea = "Ranged";
104+
105+
if (kind == 1) {
106+
Message.showInfoOfHeroPlusPrice((Hero) heroes.get(i), i + 1, kindOfAttackArea, "Sell");
107+
}
108+
if (kind == 2) {
109+
Message.showInfoOfHeroPlusPrice((Hero) heroes.get(i), i + 1, kindOfAttackArea, "Buy");
110+
}
111+
if (kind == 3) {
112+
Message.showInfoOfHeroMinusPrice((Hero) heroes.get(i), i + 1, kindOfAttackArea);
113+
}
114+
}
115+
}
116+
117+
public static void showInfoOfItems(ArrayList<Card> items, int kind) {
118+
Message.printSomeThing("_Item:");
119+
for (int i = 0, k = 1; i < items.size(); i++) {
120+
if (items.get(i).getPrice() == 0) continue;
121+
if (kind == 1) {
122+
Message.showInfoOfItemPlusPrice((Spell) items.get(i), k, "Sell");
123+
}
124+
if (kind == 2) {
125+
Message.showInfoOfItemPlusPrice((Spell) items.get(i), k, "Buy");
126+
}
127+
if (kind == 3) {
128+
Message.showInfoOfItemMinusPrice((Spell) items.get(i), k);
129+
}
130+
k++;
131+
}
132+
}
133+
134+
public static void showInfoOfOtherCards(ArrayList<Card> others, int kind) {
135+
Message.printSomeThing("_Cards:");
136+
for (int i = 0; i < others.size(); i++) {
137+
String type;
138+
if (others.get(i) instanceof Spell) type = "Spell";
139+
else type = "Minion";
140+
if (kind == 1) {
141+
Message.showInfoOfCardPlusPrice(others.get(i), i + 1, type, "Sell");
142+
}
143+
if (kind == 2) {
144+
Message.showInfoOfCardPlusPrice(others.get(i), i + 1, type, "Buy");
145+
}
146+
if (kind == 3) {
147+
Message.showInfoOfCardMinusPrice(others.get(i), i + 1, type);
148+
}
149+
}
150+
}
151+
}

0 commit comments

Comments
 (0)