-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBoard.js
More file actions
184 lines (171 loc) · 8.81 KB
/
Board.js
File metadata and controls
184 lines (171 loc) · 8.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
import Cards from './Cards.js'
class Board {
constructor(logger) {
this.logger = logger;
this.fields = [
{ position: 1, name: "Los", type: "go" },
{ position: 2, name: "Badstraße", type: "property" },
{ position: 3, name: "Gemeinschaftsfeld", type: "chest" },
{ position: 4, name: "Turmstraße", type: "property" },
{ position: 5, name: "Einkommensteuer", type: "tax" },
{ position: 6, name: "Südbahnhof", type: "station" },
{ position: 7, name: "Chausseestraße", type: "property" },
{ position: 8, name: "Ereignisfeld", type: "chance" },
{ position: 9, name: "Elisenstraße", type: "property" },
{ position: 10, name: "Poststraße", type: "property" },
{ position: 11, name: "Im Gefängnis / Nur zu Besuch", type: "jail" },
{ position: 12, name: "Seestraße", type: "property" },
{ position: 13, name: "Elektrizitätswerk", type: "utility" },
{ position: 14, name: "Hafenstraße", type: "property" },
{ position: 15, name: "Neue Straße", type: "property" },
{ position: 16, name: "Westbahnhof", type: "station" },
{ position: 17, name: "Münchner Straße", type: "property" },
{ position: 18, name: "Gemeinschaftsfeld", type: "chest" },
{ position: 19, name: "Wiener Straße", type: "property" },
{ position: 20, name: "Berliner Straße", type: "property" },
{ position: 21, name: "Frei Parken", type: "parking" },
{ position: 22, name: "Theaterstraße", type: "property" },
{ position: 23, name: "Ereignisfeld", type: "chance" },
{ position: 24, name: "Museumstraße", type: "property" },
{ position: 25, name: "Opernplatz", type: "property" },
{ position: 26, name: "Nordbahnhof", type: "property" },
{ position: 27, name: "Lessingstraße", type: "property" },
{ position: 28, name: "Schillerstraße", type: "property" },
{ position: 29, name: "Wasserwerk", type: "utility" },
{ position: 30, name: "Goethestraße", type: "property" },
{ position: 31, name: "Gehen Sie in das Gefängnis", type: "to_jail" },
{ position: 32, name: "Rathausplatz", type: "property" },
{ position: 33, name: "Hauptstraße", type: "property" },
{ position: 34, name: "Gemeinschaftsfeld", type: "chest" },
{ position: 35, name: "Bahnhofstraße", type: "property" },
{ position: 36, name: "Hauptbahnhof", type: "station" },
{ position: 37, name: "Ereignisfeld", type: "chance" },
{ position: 38, name: "Parkstraße", type: "property" },
{ position: 39, name: "Zusatzsteuer", type: "tax" },
{ position: 40, name: "Schlossallee", type: "property" },
];
this.chestCards = [
{
text: "Rücke vor bis zum nächsten Verkehrsfeld. Der Eigentümer erhält das Doppelte der normalen Miete. Hat noch kein Spieler einen Besitzanspruch auf dieses Feld, so kannst du es von der Bank kaufen.",
action: (player) => {
player.setField(this.findFieldByType("station", player.field.position));
}
},
{ text: "Du kommst aus dem Gefängnis frei. Diese Karte musst Du behalten bis Du sie benötigst oder verkaufst." },
{
text: "Gehe in das Gefängnis begib dich direkt dorthin. Gehe nicht über Los. Ziehe nicht 200€ ein.",
action: (player) => {
player.toJail(this);
}
},
{ text: "Arzt-Kosten. Zahle 50€." },
{ text: "Du hast den 2. Preis in einer Schönheitskonkurrenz gewonnen. Ziehe 10€ ein." },
{
text: "Gehe zurück zur Badstraße.",
action: (player) => {
player.setField(this.findFieldByName("Badstraße"));
}
},
{ text: "Zahle an das Krankenhaus 100€." },
{ text: "Es ist dein Geburtstag. Ziehe von jedem Spieler 10€ ein." },
{ text: "Bank-Irrtum zu deinen Gunsten. Ziehe 200€ ein." },
{ text: "Zahle eine Strafe von 10€ oder nimm eine Ereigniskarte." },
{ text: "Du erbst 100€." },
{
text: "Rücke vor bis auf Los",
action: (player) => {
player.setField(this.findFieldByName("Los"));
}
},
{ text: "Du erhältst auf Vorzugs-Aktien 7% Dividende. 25€" },
{ text: "Aus Lagerverkäufen erhältst Du 50€." },
{ text: "Einkommensteuer-Rückzahlung. Ziehe 20€ ein." },
{ text: "Die Jahresrente wird fällig. Ziehe 100€ ein." }
];
this.chanceCards = [
{ text: "Zahle Schulgeld 150€." },
{ text: "Du bist zum Vorstand gewählt worden. Zahle jedem Spieler 50€." },
{
text: "Gehe in das Gefängnis begib dich direkt dorthin. Gehe nicht über Los. Ziehe nicht 200€ ein.",
action: (player) => {
player.toJail(this);
}
},
{ text: "Du wirst zu Straßenausbesserungsarbeiten herangezogen. Zahle für deine Häuser und Hotels 40€ je Haus, 115€ je Hotel an die Bank." },
{ text: "Lasse alle deine Häuser renovieren! Zahle an die Bank: Für jedes Haus 25€, Für jedes Hotel 100€" },
{
text: "Rücke vor bis zur Seestraße. Wenn du über Los kommst, ziehe 200€ ein.",
action: (player) => {
player.setField(this.findFieldByName("Seestraße"));
}
},
{
text: "Mache eine Ausflug zum Südbahnhof. Wenn du über Los kommst, ziehe 200€ ein.",
action: (player) => {
player.setField(this.findFieldByName("Südbahnhof"));
}
},
{
text: "Rücke vor bis zur Schlossallee.",
action: (player) => {
player.setField(this.findFieldByName("Schlossallee"));
}
},
{ text: "Miete und Anleihezinsen werden fällig. Die Bank zahlt dir 150€." },
{
text: "Rücke vor bis auf Los.",
action: (player) => {
player.setField(this.findFieldByName("Los"));
}
},
{
text: "Gehe 3 Felder zurück.",
action: (player) => {
player.setField(this.findFieldByPosition(
player.getField().position <= 3
? this.getFieldCount() + player.getField().position - 3
: player.getField().position - 3
));
if(player.getField() === "chest" || player.getField() === "chance"){
this.drawCard(player.getField().type, player);
}
}
},
{ text: "Du kommst aus dem Gefängnis frei. Diese Karte musst Du behalten bis Du sie benötigst oder verkaufst." },
{
text: "Rücke vor bis zum Opernplatz. Wenn du über Los kommst, ziehe 200€ ein.",
action: (player) => {
player.setField(this.findFieldByName("Opernplatz"));
}
},
{ text: "Strafe für zu schnelles Fahren: 15€" },
{ text: "Du hast in einem Kreuzworträtsel Wettbewerb gewonnen. Ziehe 100€ ein." },
{ text: "Die Bank zahlt Dir eine Dividende: 50€" }
]
this.chest = new Cards(this.logger);
this.chance = new Cards(this.logger);
this.chest.setCards(this.chestCards);
this.chance.setCards(this.chanceCards);
this.logger.logAction("Ereigniskarten neu mischen");
this.logger.logAction("Gemeinschaftskarten neu mischen");
}
getFieldCount = () => this.fields.length;
findFieldByPosition = (position) => this.fields.find(e => e.position === position);
findFieldByName = (name) => this.fields.find(e => e.name === name);
findFieldByType = (type, offset = 0) => {
let match = this.fields.find(e => e.type === type && e.position > offset);
if (!match) match = this.fields.find(e => e.type === type);
return match;
}
drawCard = (type, player) => {
if (type === "chance") {
this.logger.logAction('Ziehe Ereigniskarte:');
this.chance.draw(player);
}
else if (type === "chest") {
this.logger.logAction('Ziehe Gemeinschaftskarte:');
this.chest.draw(player);
}
}
}
export default Board