summaryrefslogtreecommitdiff
path: root/rules.js
blob: bad1211da49d491799f46d202b413d75c81c34f4 (plain)
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
"use strict"

var game, view

// piece list:
// generals, trains, and hussars - have location (loc)
// generals - have strength (str)

// space list:
// objective/fortress have control (0 or power)

exports.roles = [ "Maria Theresa", "Frederick", "Louis XV" ]
exports.scenarios = [ "Standard", "Introductory" ]

const P_AUSTRIA = 0
const P_PRUSSIA = 1
const P_SAXONY = 2
const P_PRAGMATIC = 3
const P_FRANCE = 4
const P_BAVARIA = 5

const PLAYERS = {
	"Maria Theresa": [ P_AUSTRIA ],
	"Frederick": [ P_PRUSSIA, P_SAXONY, P_PRAGMATIC ],
	"Louis XV": [ P_FRANCE, P_BAVARIA ],
}

const MAJOR_POWERS = [ P_AUSTRIA, P_PRUSSIA, P_FRANCE, P_PRAGMATIC ]

const MINOR_POWERS = [ P_BAVARIA, P_SAXONY ]

const ALLIED = [
	[ P_FRANCE, P_BAVARIA, P_PRUSSIA, P_SAXONY ],
	[ P_AUSTRIA, P_PRAGMATIC ],
]

const COOPERATE = [
	[ P_FRANCE, P_BAVARIA ],
	[ P_PRUSSIA, P_SAXONY ],
	[ P_AUSTRIA, P_PRAGMATIC ],
]

exports.setup = function (seed, scenario, options) {
	game = {
		seed: seed,
		log: [],
		undo: [],
		active: 0, // player
		power: 0, // power
		state: "setup",

		turn: 1,
		ctl: [],
		loc: [],
		str: [],
	}

	/* SETUP

	Austria 6 Malmedy
	Austria T Geel

	Austria 1 Austerlitz
	Austria 2 Steinamanger
	Austria 3 Stuhlweißenburg
	Austria 4 Stuhlweißenburg
	Austria 5 Trübau
	Austria T Hlinsko
	Austria T Bruck
	Austria H1 Off-map
	Austria H2 Off-map

	Prussia 1 Steinau
	Prussia 2 Steinau
	Prussia 3 Sprottau
	Prussia 4 Ostpreussen Box
	Prussia T Grünberg
	Prussia T Silesia Box

	Saxony 1 Radeberg
	Saxony T Meißen

	Bavaria 1 Ergoldsbach
	Bavaria T Falkenstein

	France 1 Beaune
	France T Bar-le-Duc
	France 5 Sarreguemines
	France 4 Créspy-en-V.

	France 2 Schwandorf
	France 3 Ergoldsbach
	France T Regensburg

	Pragmatic T Tilburg
	Pragmatic 3 Dordecht
	Pragmatic 1 Delfzijl
	Pragmatic 2 Delfzijl

	*/

	return game
}


exports.view = function (state) {
	game = state
	view = {
		log: game.log
		power: game.power
		turn: game.turn,
		ctl: game.ctl,
		loc: game.loc,
		str: game.str, // TODO: redact!
	}
	return view
}