Skip to content

Commit

Permalink
Merge pull request #1 from Vagabottos/master
Browse files Browse the repository at this point in the history
Getting latest changes
  • Loading branch information
AmasaDelano authored Dec 8, 2020
2 parents 661d718 + 74e8175 commit 0f5791b
Show file tree
Hide file tree
Showing 18 changed files with 745 additions and 212 deletions.
424 changes: 260 additions & 164 deletions src/action-parser.ts

Large diffs are not rendered by default.

30 changes: 29 additions & 1 deletion src/interfaces/actions.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { Card, CardName, Faction, Item, Piece, RootLocation, Suit } from './rootgame';

export type Action = ActionGainVP | ActionCraft | ActionMove | ActionDominance | ActionCombat | ActionReveal;
export type Action = ActionGainVP | ActionCraft | ActionMove | ActionDominance | ActionCombat | ActionReveal | ActionClearPath | ActionSetOutcast | ActionSetPrices | ActionUpdateFunds | ActionTriggerPlot | ActionSwapPlots;

export interface ActionGainVP {
faction: Faction;
vp: number;
faction: Faction;
}

export interface ActionCraft {
Expand Down Expand Up @@ -44,4 +45,31 @@ export interface SubjectReveal {
export interface ActionReveal {
subjects: SubjectReveal[];
targets: Faction[];
}

export interface ActionClearPath {
clearings: number[];
}

export interface ActionSetOutcast {
degree: string; // TODO: Come up with a better name for this to distinguish between Outcast and Hated Outcast
suit: Suit;
}

export interface ActionSetPrices {
priceTypes: string[];
price: number;
}

export interface ActionUpdateFunds {
funds: number;
}

export interface ActionTriggerPlot {
plot: string;
clearing: number;
}

export interface ActionSwapPlots {
clearings: number[];
}
109 changes: 98 additions & 11 deletions src/interfaces/rootgame.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ export enum EyrieSpecial {
Build = 'b'
}

export enum EyrieLeaderSpecial {
Builder = 'builder',
Charismatic = 'charismatic',
Commander = 'commander',
Despot = 'despot'
}

export enum WoodlandSpecial {
FoxBase = 'b_f',
RabbitBase = 'b_r',
Expand All @@ -79,6 +86,18 @@ export enum VagabondItemSpecial {
Track = 't'
}

export enum VagabondCharacterSpecial {
Arbiter = 'arbiter',
Adventurer = 'adventurer',
Harrier = 'harrier',
Ranger = 'ranger',
Ronin = 'ronin',
Scoundrel = 'scoundrel',
Thief = 'thief',
Tinker = 'tinker',
Vagrant = 'vagrant'
}

export enum VagabondRelationshipStatus {
Hostile = 'h',
Indifferent = '0',
Expand All @@ -105,12 +124,29 @@ export enum LizardSpecial {
MouseGarden = 'b_m'
}

export enum LizardOutcastSpecial {
Outcast = 'o',
HatedOutcast = 'ho'
}

export enum DuchySpecial {
Citadel = 'b_c',
Market = 'b_m',
Burrow = '0'
}

export enum DuchyMinisterSpecial {
Captain = 'captain',
Marshal = 'marshal',
Foremole = 'foremole',
Banker = 'banker',
Brigadier = 'brigadier',
Mayor = 'mayor',
Baron = 'baronofdirt',
Duchess = 'duchessofmud',
Earl = 'earlofstone'
}

export enum CorvidSpecial {
Plot = 't',
BombPlot = 't_b',
Expand All @@ -123,43 +159,93 @@ export enum CardName {

// all decks
Ambush = '@',
AmbushFullName = 'ambush',
Dominance = 'dom',
DominanceFullName = 'dominance',
Anvil = 'anvil',
ArmsTrader = 'armstrader',
BakeSale = 'bakesale',
BirdyBindle = 'birdybindle',
Crossbow = 'crossbow',
FoxfolkSteel = 'foxfolksteel',
GentlyUsedKnapsack = 'gentlyusedknapsack',
Investments = 'investments',
MouseInASack = 'mouseinasack',
ProtectionRacket = 'protectionracket',
RootTea = 'roottea',
SmugglersTrail = 'smugglerstrail',
Sword = 'sword',
TravelGear = 'travelgear',
WoodlandRunners = 'woodlandrunners',

// base deck
Armor = 'armor',
ArmorFullName = 'armorers',
BetterBurrowBank = 'bank',
BetterBurrowBankFullName = 'betterburrowbank',
BrutalTactics = 'brutal',
BrutalTacticsFullName = 'brutaltactics',
CommandWarren = 'command',
CommandWarrenFullName = 'commandwarren',
Cob = 'cob',
CobFullName = 'cobbler',
Codebreakers = 'codeb',
CodebreakersFullName = 'codebreakers',
FoxFavor = 'ffavor',
FoxFavorFullName = 'favorofthefoxes',
MouseFavor = 'mfavor',
MouseFavorFullName = 'favorofthemice',
RabbitFavor = 'rfavor',
RabbitFavorFullName = 'favoroftherabbits',
GenericFavor = 'favor',
Royal = 'royal',
RoyalFullName = 'royalclaim',
Sappers = 'sap',
SappersFullName = 'sappers',
Scout = 'scout',
ScoutFullName = 'scoutingparty',
StandAndDeliver = 'stand',
StandAndDeliverFullName = 'standanddeliver',
Tax = 'tax',
TaxFullName = 'taxcollectors',

// exiles and partisans
Boat = 'boat',
BoatFullName = 'boatbuilders',
CharmOffensive = 'charm',
CharmOffensiveFullName = 'charmoffensive',
CoffinMakers = 'coffin',
CombatPlans = 'cplans',
CoffinMakersFullName = 'coffinmakers',
CorvidPlans = 'cplans',
CorvidPlansFullName = 'corvidplanners',
EyrieEmigre = 'emi',
EyrieEmigreFullName = 'eyrieemigre',
FalseOrders = 'false',
FalseOrdersFullName = 'falseorders',
FoxPartisans = 'fpart',
FoxPartisansFullName = 'foxpartisans',
RabbitPartisans = 'rpart',
RabbitPartisansFullName = 'rabbitpartisans',
MousePartisans = 'mpart',
MousePartisansFullName = 'mousepartisans',
Informers = 'inform',
InformersFullName = 'informants',
LeagueOfExtraordinaryMice = 'league',
LeagueOfExtraordinaryMiceFullName = 'leagueofextraordinarymice',
Engrave = 'engrave',
EngraveFullName = 'masterengravers',
MurineBroker = 'murine',
MurineBrokerFullName = 'murinebrokers',
PropagandaBureau = 'prop',
PropagandaBureauFullName = 'propagandabureau',
Saboteurs = 'sabo',
SaboteursFullName = 'saboteurs',
SoupKitchens = 'soup',
SoupKitchensFullName = 'soupkitchens',
SwapMeet = 'swap',
Tun = 'tun'
SwapMeetFullName = 'swapmeet',
Tun = 'tun',
TunFullName = 'tunnels'
}

export enum QuestCard {
Expand All @@ -174,15 +260,16 @@ export enum QuestCard {
Shed = 'shed'
}

export interface Forest {
clearings: number[]
}

export interface FactionBoard {
faction: Faction
}
export const SpecialCardName = Object.assign({}, EyrieLeaderSpecial, VagabondCharacterSpecial, DuchyMinisterSpecial);
export type SpecialCardName = typeof SpecialCardName;

export type RootLocation = ItemState | Faction | number | Forest | FactionBoard;
// TODO: Might need this, unsure
// export interface Location {
// index?: Number, // Clearing
// surroundingClearings?: Number[], // Forest
// faction: Faction, // Supply or Hand
// // itemState
// }

export interface Card {
suit?: Suit,
Expand All @@ -202,6 +289,6 @@ export interface RootGame {
pool?: Faction[]; // the faction pool (if using a draft)
players: Partial<Record<Faction, string>>; // { [factionkey]: player }
turns: Turn[]; // all of the game turns in order
winner: string; // the winner of the game
winner: Faction[]; // the winner(s) of the game

}
26 changes: 24 additions & 2 deletions src/parsers/conspiracy.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,28 @@
import { Action } from '../interfaces';
import { formRegex } from '../utils/regex-former';

const FLIP_PLOT_REGEX = formRegex('t<Clearing|||plotClearing>^<Piece|||plotFlipped>');
const TRICK_PLOT_REGEX = formRegex('t<Clearing|||firstClearing><->t<Clearing|||secondClearing>');

export function parseConspiracyAction(action: string): Action {
console.error(`Could not parse Conspiracy action: "${action}" - no handlers for this.`);

if (FLIP_PLOT_REGEX.test(action)) {
const result = action.match(FLIP_PLOT_REGEX);

return {
plot: result.groups.plotFlipped,
clearing: +result.groups.plotClearing
};
}

if (TRICK_PLOT_REGEX.test(action)) {
const result = action.match(TRICK_PLOT_REGEX);

return {
clearings: [+result.groups.firstClearing, +result.groups.secondClearing]
};
}

return null;
}

}
19 changes: 16 additions & 3 deletions src/parsers/cult.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
import { Action } from '../interfaces';
import { Action, Suit } from '../interfaces';
import { formRegex } from '../utils/regex-former';

const SET_OUTCAST_REGEX = formRegex('$_<Outcast|||outcastDegree>-><Suit|||outcastSuit>');

export function parseCultAction(action: string): Action {
console.error(`Could not parse Cult action: "${action}" - no handlers for this.`);

if (SET_OUTCAST_REGEX.test(action)) {
const result = action.match(SET_OUTCAST_REGEX);

return {
degree: result.groups.outcastDegree,
suit: result.groups.outcastSuit as Suit
};
}

return null;
}

}
20 changes: 17 additions & 3 deletions src/parsers/duchy.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
import { Action } from '../interfaces';
import { Action, Card, Faction } from '../interfaces';
import { formRegex } from '../utils/regex-former';

const SWAY_MINISTER_REGEX = formRegex('#<Minister|||swayedMinister>->$');

export function parseDuchyAction(action: string): Action {
console.error(`Could not parse Duchy action: "${action}" - no handlers for this.`);

if (SWAY_MINISTER_REGEX.test(action)) {
const result = action.match(SWAY_MINISTER_REGEX);

return {
things: [result.groups.swayedMinister as Card],
start: null,
end: Faction.Duchy
};
}

return null;
}

}
62 changes: 59 additions & 3 deletions src/parsers/eyrie.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,62 @@
import { Action } from '../interfaces';
import { Action, ActionMove, Card, Faction } from '../interfaces';
import { splitAction } from '../utils/action-splitter';
import { formRegex } from '../utils/regex-former';

const PURGE_DECREE_REGEX = formRegex('$_->');
const CHOOSE_LEADER_REGEX = formRegex('#<Leader|||chosenLeader>->$');
const ADD_TO_DECREE_REGEX = formRegex('[Number|||countAdded]<Card|||cardAdded>E-><Decree|||columnAdded>')


function parseAddToDecree(actions: string[]): ActionMove {

const movingComponents = [];
let destination;

for (let action of actions) {
const result = action.match(ADD_TO_DECREE_REGEX);
const number = result.groups.countAdded || 1;
const component = result.groups.cardAdded;
destination = destination || result.groups.destination;

for (let i = 0; i < number; i++) {
movingComponents.push(component);
}
}

return {
things: movingComponents,
start: null,
end: destination
};

}

export function parseEyrieAction(action: string): Action {
console.error(`Could not parse Eyrie action: "${action}" - no handlers for this.`);

if (CHOOSE_LEADER_REGEX.test(action)) {
const result = action.match(CHOOSE_LEADER_REGEX);

return {
things: [result.groups.chosenLeader as Card],
start: null,
end: Faction.Eyrie
};
}

if (PURGE_DECREE_REGEX.test(action)) {
return {
things: [], // TODO: All cards currently in Decree
start: null, // TODO: Decree (column by column?)
end: null // TODO: Discard pile
};
}

const simpleActions = splitAction(action);

if (simpleActions.every(act => ADD_TO_DECREE_REGEX.test(act))) {
return parseAddToDecree(simpleActions);
}

return null;
}

}
1 change: 0 additions & 1 deletion src/parsers/marquise.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Action } from '../interfaces';

export function parseMarquiseAction(action: string): Action {
console.error(`Could not parse Marquise action: "${action}" - no handlers for this.`);
return null;
}
Loading

0 comments on commit 0f5791b

Please sign in to comment.