-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from Vagabottos/master
Getting latest changes
- Loading branch information
Showing
18 changed files
with
745 additions
and
212 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
Oops, something went wrong.