summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--events.txt16
-rw-r--r--rules.js71
-rw-r--r--tools/gencode.js7
3 files changed, 79 insertions, 15 deletions
diff --git a/events.txt b/events.txt
index 8d29a20..644f373 100644
--- a/events.txt
+++ b/events.txt
@@ -55,7 +55,6 @@ SHADED 9
log "NOT IMPLEMENTED"
EVENT 10
- current DS
prompt "Move up to 4 Delhi Sultanate Units into adjacent Provinces."
piece_undo_opt 4 is_ds_unit(p)
prompt "Move Delhi Sultanate Unit into an adjacent space."
@@ -66,6 +65,7 @@ EVENT 10
resources DS -5
SHADED 10
+ current DS
prompt "Move any Qasbah to Spaces containing Governors."
piece_opt all is_qasbah(p)
space 1 has_governor(s) && !has_qasbah(s)
@@ -216,10 +216,18 @@ SHADED 32
log "NOT IMPLEMENTED"
EVENT 33
- log "NOT IMPLEMENTED"
+ current (has_majority_goa())
+ prompt "Remove up to 3 Opposing Units adjacent to Goa."
+ piece_opt 3 (is_adjacent_to_city(C_GOA, piece_space(p)))
+ remove
+ endpiece
+ resources (game.current) 2
SHADED 33
- log "NOT IMPLEMENTED"
+ current DS
+ prompt "Reduce Rebel Factions Resources by half."
+ resources_opt BK (-Math.floor(game.resources[BK]/2))
+ resources_opt VE (-Math.floor(game.resources[VE]/2))
EVENT 34
log "NOT IMPLEMENTED"
@@ -237,4 +245,4 @@ EVENT 36
log "NOT IMPLEMENTED"
SHADED 36
- log "NOT IMPLEMENTED" \ No newline at end of file
+ log "NOT IMPLEMENTED"
diff --git a/rules.js b/rules.js
index d73afc4..ebbd942 100644
--- a/rules.js
+++ b/rules.js
@@ -258,7 +258,7 @@ exports.setup = function (seed, scenario, _options) {
}
function setup_deck() {
- game.deck = [ 10, 37, 11, 2, 41, 3, 4, 5, 6, 7, 8, 9, 10, 1, 12, 13, 14 ]
+ game.deck = [ 33, 36, 10, 37, 11, 2, 41, 3, 4, 5, 6, 7, 8, 9, 10, 1, 12, 13, 14 ]
}
function setup_standard() {
@@ -2482,6 +2482,19 @@ function is_qasbah(p) {
return piece_name(p) === "Qasbah"
}
+/* EVENT SPECIFIC */
+
+function has_majority_goa() {
+ let c = [
+ count_faction_pieces(S_MAHARASHTRA, DS) + count_faction_pieces(S_KARNATAKA, DS),
+ count_faction_pieces(S_MAHARASHTRA, BK) + count_faction_pieces(S_KARNATAKA, BK),
+ count_faction_pieces(S_MAHARASHTRA, VE) + count_faction_pieces(S_KARNATAKA, VE)
+ ]
+ let max = Math.max(...c)
+ return c.filter(n => n === max).length > 1 ? 1 : c.indexOf(max)
+}
+
+
/* CAVALRY */
function available_cavalry() {
@@ -3357,9 +3370,6 @@ function vm_goto(cmd, nop, dir, step) {
}
function vm_inst(a) {
- console.log("In vm_inst with ", a)
- console.log(game.vm)
- console.log(CODE[game.vm.fp])
return CODE[game.vm.fp][game.vm.ip][a]
}
@@ -3408,6 +3418,18 @@ function vm_remove() {
vm_next()
}
+function vm_repeat() {
+ game.vm.n = vm_operand(1)
+ vm_next()
+}
+
+function vm_endrepeat() {
+ if (--game.vm.n === 0)
+ vm_next()
+ else
+ vm_goto(vm_repeat, vm_endrepeat, -1, 1)
+}
+
function vm_return() {
game.state = "vm_return"
}
@@ -3474,6 +3496,14 @@ states.vm_space = {
},
}
+function vm_save_space() {
+ game.vm._ss = game.vm.ss
+ game.vm._s = game.vm.s
+ game.vm.ss = []
+ game.vm.s = -1
+ vm_next()
+}
+
// VM: PIECE ITERATOR
function vm_piece() {
@@ -3549,6 +3579,10 @@ function vm_place() {
vm_next()
}
+function vm_place_space() {
+ game.vm.s = vm_operand()
+}
+
function can_vm_place_imp(s, faction, type) {
if (!can_stack_piece(s, faction, type))
return false
@@ -3621,20 +3655,27 @@ function vm_resources() {
states.vm_resources = {
prompt() {
- let f = vm_operand(1)
- let n = vm_operand(2)
+ let skip = vm_operand(1)
+ let f = vm_operand(2)
+ let n = vm_operand(3)
if (n >= 0)
event_prompt(`${faction_name[f]} +${n} Resources.`)
else
event_prompt(`${faction_name[f]} ${n} Resources.`)
gen_action_resources(f)
+
+ if (skip)
+ view.actions.skip = 1
},
resources(f) {
- let n = vm_operand(2)
+ let n = vm_operand(3)
log_resources(f, n)
add_resources(f, n)
vm_next()
},
+ skip() {
+ vm_next()
+ }
}
// === CONST ===
@@ -3789,7 +3830,6 @@ CODE[9 * 2 + 1] = [
// EVENT 10
CODE[10 * 2 + 0] = [
- [ vm_current, DS ],
[ vm_prompt, "Move up to 4 Delhi Sultanate Units into adjacent Provinces." ],
[ vm_piece, true, 0, 4, (p,s)=>is_ds_unit(p) ],
[ vm_prompt, "Move Delhi Sultanate Unit into an adjacent space." ],
@@ -3797,12 +3837,13 @@ CODE[10 * 2 + 0] = [
[ vm_move ],
[ vm_endspace ],
[ vm_endpiece ],
- [ vm_resources, DS, -5 ],
+ [ vm_resources, false, DS, -5 ],
[ vm_return ],
]
// SHADED 10
CODE[10 * 2 + 1] = [
+ [ vm_current, DS ],
[ vm_prompt, "Move any Qasbah to Spaces containing Governors." ],
[ vm_piece, false, 0, 999, (p,s)=>is_qasbah(p) ],
[ vm_space, true, 1, 1, (s)=>has_governor(s) && !has_qasbah(s) ],
@@ -4085,13 +4126,21 @@ CODE[32 * 2 + 1] = [
// EVENT 33
CODE[33 * 2 + 0] = [
- [ vm_log, "NOT IMPLEMENTED" ],
+ [ vm_current, ()=>(has_majority_goa()) ],
+ [ vm_prompt, "Remove up to 3 Opposing Units adjacent to Goa." ],
+ [ vm_piece, false, 0, 3, (p,s)=>(is_adjacent_to_city(C_GOA, piece_space(p))) ],
+ [ vm_remove ],
+ [ vm_endpiece ],
+ [ vm_resources, false, ()=>(game.current), 2 ],
[ vm_return ],
]
// SHADED 33
CODE[33 * 2 + 1] = [
- [ vm_log, "NOT IMPLEMENTED" ],
+ [ vm_current, DS ],
+ [ vm_prompt, "Reduce Rebel Factions Resources by half." ],
+ [ vm_resources, true, BK, ()=>(-Math.floor(game.resources[BK]/2)) ],
+ [ vm_resources, true, VE, ()=>(-Math.floor(game.resources[VE]/2)) ],
[ vm_return ],
]
diff --git a/tools/gencode.js b/tools/gencode.js
index d4d8d23..d155140 100644
--- a/tools/gencode.js
+++ b/tools/gencode.js
@@ -91,6 +91,13 @@ for (let line of fs.readFileSync("events.txt", "utf-8").split("\n")) {
emit([ "piece", true, 0, line[1], "(p,s)=>" + line.slice(2).join(" ") ])
break
+ case "resources":
+ emit(["resources", false, line[1], line[2]])
+ break
+ case "resources_opt":
+ emit(["resources", true, line[1], line[2]])
+ break
+
case "shipment":
emit([ "shipment", false, line[1], line[1], "(p,s)=>" + line.slice(2).join(" ") ])
break