diff options
-rw-r--r-- | events.txt | 93 | ||||
-rw-r--r-- | rules.js | 110 | ||||
-rw-r--r-- | tools/gencode.js | 3 |
3 files changed, 116 insertions, 90 deletions
@@ -42,27 +42,27 @@ SHADED 4 EVENT 5 prompt "Place Police onto Pipelines." space 1 is_pipeline(s) - place GOVT POLICE + auto_place GOVT POLICE mark_space endspace space 1 is_pipeline(s) - place GOVT POLICE + auto_place GOVT POLICE mark_space endspace space 1 is_pipeline(s) - place GOVT POLICE + auto_place GOVT POLICE mark_space endspace space 1 is_pipeline(s) - place GOVT POLICE + auto_place GOVT POLICE mark_space endspace space 1 is_pipeline(s) - place GOVT POLICE + auto_place GOVT POLICE mark_space endspace space 1 is_pipeline(s) - place GOVT POLICE + auto_place GOVT POLICE mark_space endspace prompt "Flip N Guerrillas there or adjacent to Active." @@ -153,10 +153,10 @@ SHADED 13 EVENT 14 current GOVT space 1 is_dept(s) && !is_farc_zone(s) - place GOVT BASE - place GOVT TROOPS - place GOVT TROOPS - place GOVT TROOPS + auto_place GOVT BASE + auto_place GOVT TROOPS + auto_place GOVT TROOPS + auto_place GOVT TROOPS endspace SHADED 14 @@ -241,7 +241,7 @@ EVENT 21 SHADED 21 resources FARC 6 space 1 (is_city(s) || is_dept(s)) && can_stack_base(s) - place FARC BASE + auto_place FARC BASE endspace EVENT 22 @@ -332,7 +332,7 @@ EVENT 28 SHADED 28 space 1 is_dept(s) && is_next_to_venezuela(s) && can_stack_base(s) - place FARC BASE + auto_place FARC BASE endspace space 0 is_loc(s) && is_adjacent(CUCUTA, s) && is_empty(s) sabotage @@ -408,16 +408,16 @@ EVENT 34 SHADED 34 current [FARC,AUC,CARTELS] space 1 is_zero_pop_dept(s) - place (game.current) GUERRILLA - place (game.current) GUERRILLA - place (game.current) BASE + auto_place (game.current) GUERRILLA + auto_place (game.current) GUERRILLA + auto_place (game.current) BASE endspace EVENT 35 space 1 is_dept(s) piece 0 is_piece_in_event_space(p) && is_cartels_base(p) remove - place GOVT POLICE + auto_place GOVT POLICE endpiece endspace aid 3 @@ -472,7 +472,7 @@ EVENT 39 prompt "Place Police into each of 6 Departments." # TODO: can_place space 6 is_dept(s) && !is_farc_zone(s) - place GOVT POLICE + auto_place GOVT POLICE endspace SHADED 39 @@ -481,7 +481,7 @@ SHADED 39 space_opt 3 is_dept(s) && has_police(s) piece 1 is_piece_in_event_space(p) && is_police(p) remove - place AUC GUERRILLA + auto_place AUC GUERRILLA endpiece endspace @@ -490,7 +490,7 @@ EVENT 40 piece_undo 3 is_auc_guerrilla(p) set_piece_space remove - place GOVT POLICE + auto_place GOVT POLICE endpiece SHADED 40 @@ -605,15 +605,15 @@ SHADED 47 current AUC set_space CUCUTA prompt "Place AUC Guerrillas in Cúcuta." - # space 1 s === CUCUTA - place AUC GUERRILLA - place AUC GUERRILLA + space 1 s === CUCUTA + auto_place AUC GUERRILLA + auto_place AUC GUERRILLA prompt "Execute free Terror in Cúcuta." piece 1 is_piece_in_event_space(p) && is_auc_guerrilla(p) && is_underground(p) free_terror terror_aid_cut endpiece - # endspace + endspace prompt "Flip any AUC Guerrillas Underground." piece 2 is_auc_guerrilla(p) && is_active(p) underground @@ -641,21 +641,21 @@ EVENT 49 SHADED 49 space 1 is_dept(s) - place AUC GUERRILLA - place AUC BASE + auto_place AUC GUERRILLA + auto_place AUC BASE endspace EVENT 50 # UPTO current GOVT space 1 is_dept(s) && !is_farc_zone(s) - place GOVT POLICE + auto_place GOVT POLICE endspace - space 1 is_dept(s) && !is_farc_zone(s) - place GOVT POLICE + space_opt 1 is_dept(s) && !is_farc_zone(s) + auto_place GOVT POLICE endspace - space 1 is_dept(s) && !is_farc_zone(s) - place GOVT POLICE + space_opt 1 is_dept(s) && !is_farc_zone(s) + auto_place GOVT POLICE endspace SHADED 50 @@ -689,11 +689,9 @@ EVENT 52 SHADED 52 space 1 has_auc_piece(s) && can_stack_base(s) - place AUC BASE + auto_place AUC BASE endspace - piece 0 is_auc_base(p) - resources AUC 1 - endpiece + resources AUC (count_pieces_on_map(AUC,BASE)) EVENT 53 current [FARC,AUC,CARTELS] @@ -752,7 +750,7 @@ SHADED 56 resources CARTELS 2 endpiece space 2 is_city(s) && can_stack_base(s) - place CARTELS BASE + auto_place CARTELS BASE endspace EVENT 57 @@ -760,7 +758,7 @@ EVENT 57 piece_opt 3 is_cartels_piece(p) set_piece_space remove - place GOVT POLICE + auto_place GOVT POLICE endpiece SHADED 57 @@ -820,7 +818,7 @@ EVENT 60 SHADED 60 current CARTELS space 2 is_city(s) && can_stack_base(s) - place CARTELS BASE + auto_place CARTELS BASE endspace # TODO: can_bribe space 1 is_space(s) @@ -837,7 +835,7 @@ EVENT 61 SHADED 61 space 3 !has_cartels_piece(s) && can_stack_base(s) - place CARTELS BASE + auto_place CARTELS BASE endspace EVENT 62 @@ -847,7 +845,7 @@ EVENT 62 SHADED 62 space 3 s === GUAINIA || s === VAUPES || s === AMAZONAS - place CARTELS BASE + auto_place CARTELS BASE endspace EVENT 63 @@ -892,7 +890,7 @@ EVENT 66 SHADED 66 space 0 is_forest(s) && has_cartels_base(s) && can_stack_base(s) - place CARTELS BASE + auto_place CARTELS BASE endspace EVENT 67 @@ -983,7 +981,7 @@ SHADED 71 capability space 1 s === PANAMA place (game.current) BASE - place (game.current) BASE + place_opt (game.current) BASE endspace EVENT 72 @@ -996,9 +994,10 @@ EVENT 72 SHADED 72 prompt "Place all available Cartels Guerrillas into spaces with Cartels Bases." - while has_piece(AVAILABLE, CARTELS, GUERRILLA) && count_pieces(AVAILABLE, CARTELS, BASE) < 15 - space 1 has_cartels_base(s) - # asm setup_piece(CARTELS, GUERRILLA, 1, game.vm.s) - place CARTELS GUERRILLA - endspace - endwhile + if count_pieces_on_map(CARTELS, BASE) > 0 + while has_piece(AVAILABLE, CARTELS, GUERRILLA) + space 1 has_cartels_base(s) + auto_place CARTELS GUERRILLA + endspace + endwhile + endif @@ -565,6 +565,16 @@ function count_pieces(s, faction, type) { return n } +function count_pieces_on_map(faction, type) { + let first = first_piece[faction][type] + let last = last_piece[faction][type] + let n = 0 + for (let p = first; p <= last; ++p) + if (piece_space(p) >= 0) + ++n + return n +} + function count_faction_pieces(s, faction) { switch (faction) { case GOVT: @@ -5909,6 +5919,18 @@ states.vm_shipment = { // VM: PLACE PIECE +function vm_auto_place() { + let faction = vm_operand(3) + let type = vm_operand(4) + let p = find_piece(AVAILABLE, faction, type) + if (p >= 0 && can_stack_piece(game.vm.s, faction, type)) { + place_piece(p, game.vm.s) + vm_next() + } else { + vm_place() + } +} + function vm_place() { if (can_vm_place()) game.state = "vm_place" @@ -6794,27 +6816,27 @@ const CODE = [ // EVENT 5 [ vm_prompt, "Place Police onto Pipelines." ], [ vm_space, 1, 0, 1, (s)=>is_pipeline(s) ], - [ vm_place, 0, 0, GOVT, POLICE ], + [ vm_auto_place, 0, 0, GOVT, POLICE ], [ vm_mark_space ], [ vm_endspace ], [ vm_space, 1, 0, 1, (s)=>is_pipeline(s) ], - [ vm_place, 0, 0, GOVT, POLICE ], + [ vm_auto_place, 0, 0, GOVT, POLICE ], [ vm_mark_space ], [ vm_endspace ], [ vm_space, 1, 0, 1, (s)=>is_pipeline(s) ], - [ vm_place, 0, 0, GOVT, POLICE ], + [ vm_auto_place, 0, 0, GOVT, POLICE ], [ vm_mark_space ], [ vm_endspace ], [ vm_space, 1, 0, 1, (s)=>is_pipeline(s) ], - [ vm_place, 0, 0, GOVT, POLICE ], + [ vm_auto_place, 0, 0, GOVT, POLICE ], [ vm_mark_space ], [ vm_endspace ], [ vm_space, 1, 0, 1, (s)=>is_pipeline(s) ], - [ vm_place, 0, 0, GOVT, POLICE ], + [ vm_auto_place, 0, 0, GOVT, POLICE ], [ vm_mark_space ], [ vm_endspace ], [ vm_space, 1, 0, 1, (s)=>is_pipeline(s) ], - [ vm_place, 0, 0, GOVT, POLICE ], + [ vm_auto_place, 0, 0, GOVT, POLICE ], [ vm_mark_space ], [ vm_endspace ], [ vm_prompt, "Flip N Guerrillas there or adjacent to Active." ], @@ -6905,10 +6927,10 @@ const CODE = [ // EVENT 14 [ vm_current, GOVT ], [ vm_space, 1, 0, 1, (s)=>is_dept(s) && !is_farc_zone(s) ], - [ vm_place, 0, 0, GOVT, BASE ], - [ vm_place, 0, 0, GOVT, TROOPS ], - [ vm_place, 0, 0, GOVT, TROOPS ], - [ vm_place, 0, 0, GOVT, TROOPS ], + [ vm_auto_place, 0, 0, GOVT, BASE ], + [ vm_auto_place, 0, 0, GOVT, TROOPS ], + [ vm_auto_place, 0, 0, GOVT, TROOPS ], + [ vm_auto_place, 0, 0, GOVT, TROOPS ], [ vm_endspace ], [ vm_return ], // SHADED 14 @@ -6991,7 +7013,7 @@ const CODE = [ // SHADED 21 [ vm_resources, FARC, 6 ], [ vm_space, 1, 0, 1, (s)=>(is_city(s) || is_dept(s)) && can_stack_base(s) ], - [ vm_place, 0, 0, FARC, BASE ], + [ vm_auto_place, 0, 0, FARC, BASE ], [ vm_endspace ], [ vm_return ], // EVENT 22 @@ -7082,7 +7104,7 @@ const CODE = [ [ vm_return ], // SHADED 28 [ vm_space, 1, 0, 1, (s)=>is_dept(s) && is_next_to_venezuela(s) && can_stack_base(s) ], - [ vm_place, 0, 0, FARC, BASE ], + [ vm_auto_place, 0, 0, FARC, BASE ], [ vm_endspace ], [ vm_space, 1, 0, 0, (s)=>is_loc(s) && is_adjacent(CUCUTA, s) && is_empty(s) ], [ vm_sabotage ], @@ -7157,16 +7179,16 @@ const CODE = [ // SHADED 34 [ vm_current, [FARC,AUC,CARTELS] ], [ vm_space, 1, 0, 1, (s)=>is_zero_pop_dept(s) ], - [ vm_place, 0, 0, ()=>(game.current), GUERRILLA ], - [ vm_place, 0, 0, ()=>(game.current), GUERRILLA ], - [ vm_place, 0, 0, ()=>(game.current), BASE ], + [ vm_auto_place, 0, 0, ()=>(game.current), GUERRILLA ], + [ vm_auto_place, 0, 0, ()=>(game.current), GUERRILLA ], + [ vm_auto_place, 0, 0, ()=>(game.current), BASE ], [ vm_endspace ], [ vm_return ], // EVENT 35 [ vm_space, 1, 0, 1, (s)=>is_dept(s) ], [ vm_piece, 0, 0, 0, (p,s)=>is_piece_in_event_space(p) && is_cartels_base(p) ], [ vm_remove ], - [ vm_place, 0, 0, GOVT, POLICE ], + [ vm_auto_place, 0, 0, GOVT, POLICE ], [ vm_endpiece ], [ vm_endspace ], [ vm_aid, 3 ], @@ -7220,7 +7242,7 @@ const CODE = [ // EVENT 39 [ vm_prompt, "Place Police into each of 6 Departments." ], [ vm_space, 1, 0, 6, (s)=>is_dept(s) && !is_farc_zone(s) ], - [ vm_place, 0, 0, GOVT, POLICE ], + [ vm_auto_place, 0, 0, GOVT, POLICE ], [ vm_endspace ], [ vm_return ], // SHADED 39 @@ -7228,7 +7250,7 @@ const CODE = [ [ vm_space, 1, 1, 3, (s)=>is_dept(s) && has_police(s) ], [ vm_piece, 0, 0, 1, (p,s)=>is_piece_in_event_space(p) && is_police(p) ], [ vm_remove ], - [ vm_place, 0, 0, AUC, GUERRILLA ], + [ vm_auto_place, 0, 0, AUC, GUERRILLA ], [ vm_endpiece ], [ vm_endspace ], [ vm_return ], @@ -7237,7 +7259,7 @@ const CODE = [ [ vm_piece, 1, 0, 3, (p,s)=>is_auc_guerrilla(p) ], [ vm_set_piece_space ], [ vm_remove ], - [ vm_place, 0, 0, GOVT, POLICE ], + [ vm_auto_place, 0, 0, GOVT, POLICE ], [ vm_endpiece ], [ vm_return ], // SHADED 40 @@ -7352,13 +7374,15 @@ const CODE = [ [ vm_current, AUC ], [ vm_set_space, CUCUTA ], [ vm_prompt, "Place AUC Guerrillas in Cúcuta." ], - [ vm_place, 0, 0, AUC, GUERRILLA ], - [ vm_place, 0, 0, AUC, GUERRILLA ], + [ vm_space, 1, 0, 1, (s)=>s === CUCUTA ], + [ vm_auto_place, 0, 0, AUC, GUERRILLA ], + [ vm_auto_place, 0, 0, AUC, GUERRILLA ], [ vm_prompt, "Execute free Terror in Cúcuta." ], [ vm_piece, 0, 0, 1, (p,s)=>is_piece_in_event_space(p) && is_auc_guerrilla(p) && is_underground(p) ], [ vm_free_terror ], [ vm_terror_aid_cut ], [ vm_endpiece ], + [ vm_endspace ], [ vm_prompt, "Flip any AUC Guerrillas Underground." ], [ vm_piece, 0, 0, 2, (p,s)=>is_auc_guerrilla(p) && is_active(p) ], [ vm_underground ], @@ -7386,20 +7410,20 @@ const CODE = [ [ vm_return ], // SHADED 49 [ vm_space, 1, 0, 1, (s)=>is_dept(s) ], - [ vm_place, 0, 0, AUC, GUERRILLA ], - [ vm_place, 0, 0, AUC, BASE ], + [ vm_auto_place, 0, 0, AUC, GUERRILLA ], + [ vm_auto_place, 0, 0, AUC, BASE ], [ vm_endspace ], [ vm_return ], // EVENT 50 [ vm_current, GOVT ], [ vm_space, 1, 0, 1, (s)=>is_dept(s) && !is_farc_zone(s) ], - [ vm_place, 0, 0, GOVT, POLICE ], + [ vm_auto_place, 0, 0, GOVT, POLICE ], [ vm_endspace ], - [ vm_space, 1, 0, 1, (s)=>is_dept(s) && !is_farc_zone(s) ], - [ vm_place, 0, 0, GOVT, POLICE ], + [ vm_space, 1, 1, 1, (s)=>is_dept(s) && !is_farc_zone(s) ], + [ vm_auto_place, 0, 0, GOVT, POLICE ], [ vm_endspace ], - [ vm_space, 1, 0, 1, (s)=>is_dept(s) && !is_farc_zone(s) ], - [ vm_place, 0, 0, GOVT, POLICE ], + [ vm_space, 1, 1, 1, (s)=>is_dept(s) && !is_farc_zone(s) ], + [ vm_auto_place, 0, 0, GOVT, POLICE ], [ vm_endspace ], [ vm_return ], // SHADED 50 @@ -7432,11 +7456,9 @@ const CODE = [ [ vm_return ], // SHADED 52 [ vm_space, 1, 0, 1, (s)=>has_auc_piece(s) && can_stack_base(s) ], - [ vm_place, 0, 0, AUC, BASE ], + [ vm_auto_place, 0, 0, AUC, BASE ], [ vm_endspace ], - [ vm_piece, 0, 0, 0, (p,s)=>is_auc_base(p) ], - [ vm_resources, AUC, 1 ], - [ vm_endpiece ], + [ vm_resources, AUC, ()=>(count_pieces_on_map(AUC,BASE)) ], [ vm_return ], // EVENT 53 [ vm_current, [FARC,AUC,CARTELS] ], @@ -7494,7 +7516,7 @@ const CODE = [ [ vm_resources, CARTELS, 2 ], [ vm_endpiece ], [ vm_space, 1, 0, 2, (s)=>is_city(s) && can_stack_base(s) ], - [ vm_place, 0, 0, CARTELS, BASE ], + [ vm_auto_place, 0, 0, CARTELS, BASE ], [ vm_endspace ], [ vm_return ], // EVENT 57 @@ -7502,7 +7524,7 @@ const CODE = [ [ vm_piece, 0, 1, 3, (p,s)=>is_cartels_piece(p) ], [ vm_set_piece_space ], [ vm_remove ], - [ vm_place, 0, 0, GOVT, POLICE ], + [ vm_auto_place, 0, 0, GOVT, POLICE ], [ vm_endpiece ], [ vm_return ], // SHADED 57 @@ -7562,7 +7584,7 @@ const CODE = [ // SHADED 60 [ vm_current, CARTELS ], [ vm_space, 1, 0, 2, (s)=>is_city(s) && can_stack_base(s) ], - [ vm_place, 0, 0, CARTELS, BASE ], + [ vm_auto_place, 0, 0, CARTELS, BASE ], [ vm_endspace ], [ vm_space, 1, 0, 1, (s)=>is_space(s) ], [ vm_free_bribe ], @@ -7578,7 +7600,7 @@ const CODE = [ [ vm_return ], // SHADED 61 [ vm_space, 1, 0, 3, (s)=>!has_cartels_piece(s) && can_stack_base(s) ], - [ vm_place, 0, 0, CARTELS, BASE ], + [ vm_auto_place, 0, 0, CARTELS, BASE ], [ vm_endspace ], [ vm_return ], // EVENT 62 @@ -7588,7 +7610,7 @@ const CODE = [ [ vm_return ], // SHADED 62 [ vm_space, 1, 0, 3, (s)=>s === GUAINIA || s === VAUPES || s === AMAZONAS ], - [ vm_place, 0, 0, CARTELS, BASE ], + [ vm_auto_place, 0, 0, CARTELS, BASE ], [ vm_endspace ], [ vm_return ], // EVENT 63 @@ -7633,7 +7655,7 @@ const CODE = [ [ vm_return ], // SHADED 66 [ vm_space, 1, 0, 0, (s)=>is_forest(s) && has_cartels_base(s) && can_stack_base(s) ], - [ vm_place, 0, 0, CARTELS, BASE ], + [ vm_auto_place, 0, 0, CARTELS, BASE ], [ vm_endspace ], [ vm_return ], // EVENT 67 @@ -7723,7 +7745,7 @@ const CODE = [ [ vm_capability ], [ vm_space, 1, 0, 1, (s)=>s === PANAMA ], [ vm_place, 0, 0, ()=>(game.current), BASE ], - [ vm_place, 0, 0, ()=>(game.current), BASE ], + [ vm_place, 0, 1, ()=>(game.current), BASE ], [ vm_endspace ], [ vm_return ], // EVENT 72 @@ -7736,12 +7758,14 @@ const CODE = [ [ vm_return ], // SHADED 72 [ vm_prompt, "Place all available Cartels Guerrillas into spaces with Cartels Bases." ], - [ vm_while, ()=>has_piece(AVAILABLE, CARTELS, GUERRILLA) && count_pieces(AVAILABLE, CARTELS, BASE) < 15 ], + [ vm_if, ()=>count_pieces_on_map(CARTELS, BASE) > 0 ], + [ vm_while, ()=>has_piece(AVAILABLE, CARTELS, GUERRILLA) ], [ vm_space, 1, 0, 1, (s)=>has_cartels_base(s) ], - [ vm_place, 0, 0, CARTELS, GUERRILLA ], + [ vm_auto_place, 0, 0, CARTELS, GUERRILLA ], [ vm_endspace ], [ vm_endwhile ], + [ vm_endif ], [ vm_return ], ] -const UCODE = [0,1,7,13,19,29,65,79,85,92,98,104,110,116,122,139,146,153,159,166,176,189,199,206,222,236,248,258,266,279,293,303,314,320,332,341,354,364,377,389,402,424,436,445,459,469,480,497,519,532,541,558,572,583,599,613,627,636,651,664,684,699,710,718,730,744,749,757,762,782,811,825,838] -const SCODE = [0,4,10,16,24,59,70,82,90,95,101,107,113,119,130,142,151,156,162,0,183,194,203,215,227,242,253,263,272,287,300,310,318,326,334,349,0,369,383,394,409,431,441,453,464,473,0,504,528,536,552,567,576,0,0,622,629,643,656,672,691,706,714,0,735,0,753,759,777,0,816,832,845] +const UCODE = [0,1,7,13,19,29,65,79,85,92,98,104,110,116,122,139,146,153,159,166,176,189,199,206,222,236,248,258,266,279,293,303,314,320,332,341,354,364,377,389,402,424,436,445,459,469,480,497,521,534,543,560,574,583,599,613,627,636,651,664,684,699,710,718,730,744,749,757,762,782,811,825,838] +const SCODE = [0,4,10,16,24,59,70,82,90,95,101,107,113,119,130,142,151,156,162,0,183,194,203,215,227,242,253,263,272,287,300,310,318,326,334,349,0,369,383,394,409,431,441,453,464,473,0,504,530,538,554,569,578,0,0,622,629,643,656,672,691,706,714,0,735,0,753,759,777,0,816,832,845] diff --git a/tools/gencode.js b/tools/gencode.js index 4ac01d1..efe1556 100644 --- a/tools/gencode.js +++ b/tools/gencode.js @@ -94,6 +94,9 @@ for (let line of fs.readFileSync("events.txt", "utf-8").split("\n")) { case "place_undo": emit([ "place", 1, 0, line[1], line[2] ]) break + case "auto_place": + emit([ "auto_place", 0, 0, line[1], line[2] ]) + break case "log": case "prompt": |