Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'remotes/master-origin/dor' into dor-sie…
Browse files Browse the repository at this point in the history
…ge-warfare
  • Loading branch information
marcsoiferman-cm committed Nov 22, 2019
2 parents 04b147f + 42e1835 commit 90ab921
Show file tree
Hide file tree
Showing 83 changed files with 4,337 additions and 262 deletions.
7 changes: 4 additions & 3 deletions client/GameComponents/Card.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ class Card extends React.Component {
cardHeight *= 2;
break;
}

let attachmentCount = this.props.source === 'play area' ? _.size(this.props.card.attachments) : 0;
let attachments = this.props.card.attachments;
let totalTiers = 0;
Expand All @@ -227,8 +228,8 @@ class Card extends React.Component {
}

getAttachments() {

if(this.props.source !== 'play area') {
const provinces = ['province 1', 'province 2', 'province 3', 'province 4', 'stronghold province'];
if(this.props.source !== 'play area' && !provinces.includes(this.props.source)) {
return null;
}

Expand Down Expand Up @@ -495,7 +496,7 @@ class Card extends React.Component {
render() {
if(this.props.wrapped) {
return (
<div className={ 'card-wrapper ' + this.getWrapper() } style={ Object.assign({}, this.props.style ? this.props.style : {},this.getWrapperStyle()) }>
<div className={ 'card-wrapper ' + this.getWrapper() } style={ Object.assign({}, this.props.style ? this.props.style : {}, this.getWrapperStyle()) }>
{ this.getCard() }
{ this.getAttachments() }
</div>);
Expand Down
37 changes: 36 additions & 1 deletion client/GameComponents/Province.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,41 @@ class Province extends React.Component {
}
}

getWrapperStyle(provinceCard) {
let wrapperStyle = {};
let attachmentOffset = 13;
let cardHeight = 84;
switch(this.props.size) {
case 'large':
attachmentOffset *= 1.4;
cardHeight *= 1.4;
break;
case 'small':
attachmentOffset *= 0.8;
cardHeight *= 0.8;
break;
case 'x-large':
attachmentOffset *= 2;
cardHeight *= 2;
break;
}

let attachmentCount = _.size(provinceCard.attachments);
let attachments = provinceCard.attachments;
let totalTiers = 0;
_.forEach(attachments, attachment => {
if(attachment.bowed) {
totalTiers += 1;
}
});

if(attachmentCount > 0) {
wrapperStyle = { marginLeft:(4 + attachmentCount * attachmentOffset) + 'px', minHeight: (cardHeight + totalTiers * attachmentOffset) + 'px' };
}

return wrapperStyle;
}

render() {
var className = 'panel province ' + this.props.size;
var cardCount = this.props.cardCount || (this.props.cards ? this.props.cards.length : '0');
Expand Down Expand Up @@ -89,7 +124,7 @@ class Province extends React.Component {

return (
<div className={ className } onDragLeave={ this.onDragLeave } onDragOver={ this.onDragOver } onDrop={ event => this.onDragDrop(event, this.props.source) }
onClick={ this.onCollectionClick }>
onClick={ this.onCollectionClick } style={ provinceCard ? Object.assign({}, this.getWrapperStyle(provinceCard)) : {} }>
<div className='panel-header'>
{ headerText }
</div>
Expand Down
2 changes: 1 addition & 1 deletion fiveringsdb-data
Submodule fiveringsdb-data updated 51 files
+35 −0 json/Card/agasha-hiyori.json
+41 −0 json/Card/an-ocean-in-a-drop.json
+35 −0 json/Card/asahina-maeko.json
+35 −0 json/Card/bayushi-gensato.json
+41 −0 json/Card/desolation.json
+40 −0 json/Card/elegant-tessen.json
+35 −0 json/Card/favorable-dealbroker.json
+41 −0 json/Card/four-temples-advisor.json
+38 −0 json/Card/fruitful-respite.json
+34 −0 json/Card/fuchi-mura.json
+2 −2 json/Card/henshin-mysteries.json
+40 −0 json/Card/hida-kotoe.json
+35 −0 json/Card/hida-sukune.json
+42 −0 json/Card/ichiro.json
+41 −0 json/Card/iron-foundations-stance.json
+36 −0 json/Card/isawa-eju.json
+35 −0 json/Card/iuchi-rimei.json
+34 −0 json/Card/kaiu-forges.json
+36 −0 json/Card/kaiu-siege-force.json
+40 −0 json/Card/kansen-haunt.json
+34 −0 json/Card/kuni-wastelands.json
+36 −0 json/Card/matsu-agetoki.json
+35 −0 json/Card/matsu-koso.json
+36 −0 json/Card/mirumoto-masashige.json
+35 −0 json/Card/monastery-protector.json
+42 −0 json/Card/moto-eviscerator.json
+35 −0 json/Card/niten.json
+34 −0 json/Card/perceptive-kitsuki.json
+35 −0 json/Card/purifier-apprentice.json
+40 −0 json/Card/reinforced-plate.json
+34 −0 json/Card/seventh-tower.json
+35 −0 json/Card/shadowlands-hunter.json
+35 −0 json/Card/shinjo-yasamura.json
+34 −0 json/Card/shintao-monastery.json
+41 −0 json/Card/slovenly-scavenger.json
+36 −0 json/Card/taoist-adept.json
+40 −0 json/Card/the-strength-of-the-mountain.json
+1 −1 json/Card/the-wrath-of-the-kami.json
+34 −0 json/Card/third-whisker-warrens.json
+41 −0 json/Card/togashi-acolyte.json
+35 −0 json/Card/togashi-mitsu-2.json
+34 −0 json/Card/unyielding-sensei.json
+41 −0 json/Card/wildfire-kick.json
+2 −2 json/Card/yasuki-hikaru.json
+34 −0 json/Card/yogo-asami.json
+20 −0 json/Label/en.json
+26 −26 json/PackCard/a-champion-s-foresight.json
+188 −12 json/PackCard/defenders-of-rokugan.json
+2 −2 json/PackCard/into-the-forbidden-city.json
+162 −2 json/PackCard/seekers-of-wisdom.json
+18 −0 json/Translation/core/de.json
1 change: 0 additions & 1 deletion server/game/CardSelector.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ const MaxStatCardSelector = require('./CardSelectors/MaxStatCardSelector');
const SingleCardSelector = require('./CardSelectors/SingleCardSelector');
const UnlimitedCardSelector = require('./CardSelectors/UnlimitedCardSelector');
const UpToXCardSelector = require('./CardSelectors/UpToXCardSelector');

const { TargetModes, CardTypes } = require('./Constants');

const defaultProperties = {
Expand Down
4 changes: 3 additions & 1 deletion server/game/Constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export enum EffectNames {
DelayedEffect = 'delayedEffect',
DoesNotBow = 'doesNotBow',
DoesNotReady = 'doesNotReady',
FateCostToAttack = 'fateCostToAttack',
GainAbility = 'gainAbility',
GainExtraFateWhenPlayed = 'gainExtraFateWhenPlayed',
GainPlayAction = 'gainPlayAction',
Expand Down Expand Up @@ -115,7 +116,8 @@ export enum EffectNames {
ChangeConflictSkillFunction = 'skillFunction',
ModifyConflictElementsToResolve = 'modifyConflictElementsToResolve',
RestrictNumberOfDefenders = 'restrictNumberOfDefenders',
ResolveConflictEarly = 'resolveConflictEarly'
ResolveConflictEarly = 'resolveConflictEarly',
SetBaseGlory = "setBaseGlory"
};

export enum Durations {
Expand Down
4 changes: 4 additions & 0 deletions server/game/Effects/EffectValue.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ class EffectValue {
return this.value;
}

recalculate() {
return false;
}

setContext(context) {
this.context = context;
}
Expand Down
2 changes: 1 addition & 1 deletion server/game/Effects/StaticEffect.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class StaticEffect {
}

recalculate() {
return false;
return this.value.recalculate();
}

setContext(context) {
Expand Down
21 changes: 21 additions & 0 deletions server/game/Effects/SuppressEffect.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const EffectValue = require('./EffectValue');

class SuppressEffect extends EffectValue {
constructor(predicate) {
super([]);
this.predicate = predicate;
}

recalculate() {
if(typeof this.predicate !== 'function') {
return false;
}
const oldValue = this.value;
const suppressedEffects = this.context.game.effectEngine.effects.filter(effect => this.predicate(effect.effect));
const newValue = suppressedEffects.map(effect => effect.effect);
this.setValue(newValue);
return oldValue.length !== newValue.length || oldValue.some(element => !newValue.includes(element));
}
}

module.exports = SuppressEffect;
3 changes: 2 additions & 1 deletion server/game/Effects/restriction.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const EffectValue = require('./EffectValue');

const { CardTypes } = require('../Constants');
const { AbilityTypes, CardTypes } = require('../Constants');

const checkRestrictions = {
attachmentsWithSameClan: (context, effect, card) =>
Expand All @@ -24,6 +24,7 @@ const checkRestrictions = {
context.player && context.player === effect.context.player.opponent && context.source.type === 'ring',
opponentsTriggeredAbilities: (context, effect) =>
context.player === effect.context.player.opponent && context.ability.isTriggeredAbility(),
reactions: context => context.ability.abilityType === AbilityTypes.Reaction,
source: (context, effect) => context.source === effect.context.source
};

Expand Down
7 changes: 4 additions & 3 deletions server/game/GameActions/AttachAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export interface AttachActionProperties extends CardActionProperties {
export class AttachAction extends CardGameAction {
name = 'attach';
eventName = EventNames.OnCardAttached;
targetType = [CardTypes.Character];
targetType = [CardTypes.Character, CardTypes.Province];
defaultProperties: AttachActionProperties = {
ignoreType: false,
takeControl: false
Expand All @@ -33,7 +33,7 @@ export class AttachAction extends CardGameAction {

canAffect(card: BaseCard, context: AbilityContext, additionalProperties = {}): boolean {
let properties = this.getProperties(context, additionalProperties) as AttachActionProperties;
if(!context || !context.player || !card || card.location !== Locations.PlayArea) {
if(!context || !context.player || !card || card.location !== Locations.PlayArea && card.type !== CardTypes.Province) {
return false;
} else if(!properties.attachment || properties.attachment.anotherUniqueInPlay(context.player) || !properties.attachment.canAttach(card, context, properties.ignoreType)) {
return false;
Expand All @@ -42,7 +42,8 @@ export class AttachAction extends CardGameAction {
}
return card.allowAttachment(properties.attachment) && super.canAffect(card, context);
}



checkEventCondition(event, additionalProperties): boolean {
return this.canAffect(event.parent, event.context, additionalProperties);
}
Expand Down
8 changes: 4 additions & 4 deletions server/game/GameActions/CardGameAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class CardGameAction extends GameAction {
const additionalCosts = card.getEffects(EffectNames.UnlessActionCost).filter(properties => properties.actionName === this.name);
if(additionalCosts.length > 0) {
let allCostsPaid = true;
for(const properties of additionalCosts) {
for(const properties of additionalCosts) {
context.game.queueSimpleStep(() => {
let cost = properties.cost;
if(typeof cost === 'function') {
Expand All @@ -52,11 +52,11 @@ export class CardGameAction extends GameAction {
context.game.addMessage('{0} chooses not to {1}', card.controller, this.getEffectMessage(context, additionalProperties));
}
]
});
});
} else {
allCostsPaid = false;
context.game.addMessage('{0} cannot pay the additional cost required to {1}', card.controller, this.getEffectMessage(context, additionalProperties));
}
}
});
}
context.game.queueSimpleStep(() => {
Expand Down Expand Up @@ -114,7 +114,7 @@ export class CardGameAction extends GameAction {
fateEvent.isContingent = true;
contingentEvents.push(fateEvent);
}
return contingentEvents;
return contingentEvents;
}
}

Expand Down
2 changes: 1 addition & 1 deletion server/game/GameActions/DiscardStatusAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export class DiscardStatusAction extends TokenAction {
cost = 'discarding {0}\'s status token';

eventHandler(event): void {
if(event.token.card.personalHonor === event.token) {
if(event.token.card && event.token.card.personalHonor === event.token) {
event.token.card.makeOrdinary();
}
}
Expand Down
8 changes: 5 additions & 3 deletions server/game/GameActions/MultipleGameAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,11 @@ export class MultipleGameAction extends GameAction {
addEventsToArray(events: any[], context: AbilityContext, additionalProperties = {}): void {
let properties = this.getProperties(context, additionalProperties);
for(const gameAction of properties.gameActions) {
if(gameAction.hasLegalTarget(context, additionalProperties)) {
gameAction.addEventsToArray(events, context, additionalProperties);
}
context.game.queueSimpleStep(() => {
if(gameAction.hasLegalTarget(context, additionalProperties)) {
gameAction.addEventsToArray(events, context, additionalProperties);
}
});
}
}

Expand Down
19 changes: 18 additions & 1 deletion server/game/GameActions/PlayCardAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import AbilityResolver = require('../gamesteps/abilityresolver');
import DrawCard = require('../drawcard');
import Event = require('../Events/Event');
import { CardGameAction, CardActionProperties } from './CardGameAction';
import { Locations, PlayTypes } from '../Constants';
import { Locations, PlayTypes, Stages } from '../Constants';

class PlayCardResolver extends AbilityResolver {
playGameAction: PlayCardAction;
Expand All @@ -18,6 +18,21 @@ class PlayCardResolver extends AbilityResolver {
this.cancelPressed = false;
}

resolveEarlyTargets() {
if(this.gameActionProperties.playCardTarget) {
this.context.stage = Stages.PreTarget;
this.targetResults = {
canIgnoreAllCosts: false,
cancelled: false,
payCostsFirst: false,
delayTargeting: null
};
this.gameActionProperties.playCardTarget(this.context, this.gameActionProperties);
} else {
super.resolveEarlyTargets();
}
}

checkForCancel() {
super.checkForCancel();
if(this.cancelled && this.gameActionProperties.resetOnCancel) {
Expand Down Expand Up @@ -67,6 +82,8 @@ export interface PlayCardProperties extends CardActionProperties {
resetOnCancel?: boolean;
postHandler?: (context: AbilityContext) => void;
playType?: PlayTypes;
playCardTarget?: (context: AbilityContext, properties: PlayCardProperties) => void;
location?: Locations;
destination?: Locations;
destinationOptions?: object;
payCosts?: boolean;
Expand Down
12 changes: 3 additions & 9 deletions server/game/GameObject.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,16 @@ class GameObject {
}

getEffects(type) {
let suppressedEffects = this.getSuppressedEffects();
let filteredEffects = this.effects.filter(effect => effect.type === type && !suppressedEffects.includes(effect));
let filteredEffects = this.getRawEffects().filter(effect => effect.type === type);
return filteredEffects.map(effect => effect.getValue(this));
}

getRawEffects() {
let suppressedEffects = this.getSuppressedEffects();
const suppressEffects = this.effects.filter(effect => effect.type === EffectNames.SuppressEffects);
const suppressedEffects = suppressEffects.reduce((array, effect) => array.concat(effect.getValue(this)), []);
return this.effects.filter(effect => !suppressedEffects.includes(effect));
}

getSuppressedEffects() {
let suppressingEffects = this.effects.filter(effect => effect.type === EffectNames.SuppressEffects);
let suppressedEffects = this.effects.filter(effect => suppressingEffects.some(suppressingEffect => suppressingEffect.value.value(effect)));
return suppressedEffects;
}

sumEffects(type) {
let filteredEffects = this.getEffects(type);
return filteredEffects.reduce((total, effect) => total + effect, 0);
Expand Down
5 changes: 5 additions & 0 deletions server/game/Interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,12 +163,17 @@ export interface PersistentEffectProps {
effect: Function | Function[];
};

export type traitLimit = {
[trait: string]: number
};

export interface AttachmentConditionProps {
limit?: number;
myControl?: boolean;
unique?: boolean;
faction?: string | string[];
trait?: string | string[];
limitTrait?: traitLimit | traitLimit[]
};

interface HonoredToken {
Expand Down
Loading

0 comments on commit 90ab921

Please sign in to comment.