Skip to content

Commit

Permalink
Add several character states
Browse files Browse the repository at this point in the history
Hero: Frozen, Immune
Minion: Enraged, Immune, Silenced, Untargetable, Buffed

Progress on #7.
  • Loading branch information
azeier authored and beheh committed Oct 10, 2016
1 parent 2dd87c2 commit 33e0182
Show file tree
Hide file tree
Showing 16 changed files with 106 additions and 14 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]
### Added
- Add several character states (#7, @azeier)

## [0.8.0] - 2016-10-10
### Added
Expand Down
Binary file added assets/images/inplay_hero_frozen.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/inplay_hero_immune.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/inplay_minion_buffed.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/inplay_minion_enraged.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/inplay_minion_immune.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/inplay_minion_silenced.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/inplay_minion_untargetable.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 3 additions & 2 deletions less/entities.less
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@
div.visuals {
.inplay-base, .inplay-legendary, .inplay-taunt, .inplay-shield, .inplay-frozen, .inplay-divine-shield,
.inplay-stealth, .icon-deathrattle, .icon-trigger, .icon-inspire, .icon-poisonous,
.effect-sleep {
.effect-sleep, .inplay-enraged, .inplay-silenced, .inplay-immune, .inplay-untargetable,
.inplay-buffed {
height: 100%;
}
.inplay-divine-shield {
Expand Down Expand Up @@ -257,7 +258,7 @@
}

div.visuals {
.hero-frame, .hero-attack, .hero-armor, .secret{
.hero-frame, .hero-attack, .hero-armor, .secret, .hero-frozen, .hero-immune {
height: 100%;
}
.skull {
Expand Down
16 changes: 16 additions & 0 deletions ts/Entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,14 @@ export default class Entity {
return this.getTag(GameTag.STEALTH) > 0;
}

public isImmune():boolean {
return this.getTag(GameTag.IMMUNE) > 0;
}

public isSilenced():boolean {
return this.getTag(GameTag.SILENCED) > 0;
}

public isDivineShielded():boolean {
return this.getTag(GameTag.DIVINE_SHIELD) > 0;
}
Expand All @@ -96,6 +104,14 @@ export default class Entity {
return this.getTag(GameTag.FROZEN) > 0;
}

public isEnraged():boolean {
return this.getTag(GameTag.ENRAGED) > 0 && this.getDamage() > 0;
}

public cantBeTargeted():boolean {
return this.getTag(GameTag.CANT_BE_TARGETED_BY_ABILITIES) > 0;
}

public getZonePosition():number {
return this.getTag(GameTag.ZONE_POSITION);
}
Expand Down
34 changes: 23 additions & 11 deletions ts/components/game/Field.tsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,39 @@
import * as React from "react";
import EntityInPlay from "./EntityInPlay";
import * as _ from "lodash";
import EntityList from "./EntityList";
import Entity from "../../Entity";
import Option from "../../Option";
import Minion from "./Minion";
import {EntityListProps} from "../../interfaces";

import {EntityInPlayProps, EntityListProps} from "../../interfaces";
interface FieldProps extends EntityListProps {
buffedEntities?: number[];
}

export default class Field extends EntityList<EntityListProps> {
export default class Field extends EntityList<FieldProps> {

protected className(): string {
return 'field';
}

protected renderEntity(entity: Entity, option: Option) {
return (<Minion entity={entity}
option={option}
optionCallback={this.props.optionCallback}
assetDirectory={this.props.assetDirectory}
cardArtDirectory={this.props.cardArtDirectory}
cards={this.props.cards}
controller={this.props.controller}
descriptors={this.props.descriptors}
/>);
option={option}
optionCallback={this.props.optionCallback}
assetDirectory={this.props.assetDirectory}
cardArtDirectory={this.props.cardArtDirectory}
cards={this.props.cards}
controller={this.props.controller}
descriptors={this.props.descriptors}
buffed={entity && this.props.buffedEntities && this.props.buffedEntities.indexOf(entity.id) !== -1}
/>);
}


public shouldComponentUpdate(nextProps: FieldProps, nextState): boolean {
if (!_.isEqual(nextProps.buffedEntities, this.props.buffedEntities)) {
return true;
}
return super.shouldComponentUpdate(nextProps, nextState);
}
}
1 change: 1 addition & 0 deletions ts/components/game/Minion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export default class Minion extends EntityInPlay<EntityInPlayProps> {
cardArtDirectory={this.props.cardArtDirectory}
damage={damage}
healing={healing}
buffed={this.props.buffed}
/>,
<div key="stats" className="stats">
{entity.getTag(GameTag.HIDE_STATS) == 0 ? [
Expand Down
9 changes: 9 additions & 0 deletions ts/components/game/Player.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,14 @@ export default class Player extends React.Component<PlayerProps, void> {
let playEntities = this.props.entities.get(Zone.PLAY) || Immutable.Map<number, Entity>();
let playOptions = this.props.options.get(Zone.PLAY) || Immutable.Map<number, Option>();

let buffedEntities = [];
playEntities.forEach(entity => {
let attached = entity.getTag(GameTag.ATTACHED);
if (attached && buffedEntities.indexOf(attached) === -1) {
buffedEntities.push(attached);
}
});

/* Equipment */
let heroEntity = playEntities.filter(filterByCardType(CardType.HERO)).first();
if (!heroEntity) {
Expand Down Expand Up @@ -170,6 +178,7 @@ export default class Player extends React.Component<PlayerProps, void> {
cardArtDirectory={this.props.cardArtDirectory}
controller={this.props.player}
descriptors={this.props.descriptors}
buffedEntities={buffedEntities}
/>;
let deck = <Deck entities={this.props.entities.get(Zone.DECK) || emptyEntities}
options={this.props.options.get(Zone.DECK) || emptyOptions}
Expand Down
14 changes: 14 additions & 0 deletions ts/components/game/visuals/HeroArt.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,20 @@ export default class HeroArt extends React.Component<HeroArtProps, void> {
classes: ["hero-frame"]
});

if (entity.isFrozen()) {
images.push({
image: "inplay_hero_frozen.png",
classes: ["hero-frozen"]
});
}

if (entity.isImmune()) {
images.push({
image: "inplay_hero_immune.png",
classes: ["hero-immune"]
});
}

if (entity.getAtk() > 0) {
images.push({
image: "hero_attack.png",
Expand Down
38 changes: 37 additions & 1 deletion ts/components/game/visuals/InPlayCardArt.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ export default class InPlayCardArt extends React.Component<EntityProps, void> {
nextProps.healing !== this.props.healing ||
nextProps.controller !== this.props.controller ||
nextProps.assetDirectory !== this.props.assetDirectory ||
nextProps.cardArtDirectory !== this.props.cardArtDirectory
nextProps.cardArtDirectory !== this.props.cardArtDirectory ||
nextProps.buffed !== this.props.buffed
);
}

Expand Down Expand Up @@ -46,6 +47,13 @@ export default class InPlayCardArt extends React.Component<EntityProps, void> {
});
}

if (entity.cantBeTargeted()) {
images.push({
image: "inplay_minion_untargetable.png",
classes: ["inplay-untargetable"]
});
}

if (entity.getTag(GameTag.HIDE_STATS)) {
images.push({
image: `inplay_minion_hide_stats${postfix}.png`,
Expand Down Expand Up @@ -79,6 +87,34 @@ export default class InPlayCardArt extends React.Component<EntityProps, void> {
});
}

if (entity.isImmune()) {
images.push({
image: "inplay_minion_immune.png",
classes: ["inplay-immune"]
});
}

if (entity.isSilenced()) {
images.push({
image: "inplay_minion_silenced.png",
classes: ["inplay-silenced"]
});
}

if (entity.isEnraged()) {
images.push({
image: "inplay_minion_enraged.png",
classes: ["inplay-enraged"]
});
}

if (this.props.buffed) {
images.push({
image: "inplay_minion_buffed.png",
classes: ["inplay-buffed"]
});
}

if (entity.getTag(GameTag.INSPIRE) > 0) {
images.push({
image: "icon_inspire.png",
Expand Down
1 change: 1 addition & 0 deletions ts/interfaces.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export interface EntityProps extends CardDataProps, ControllerProps, AssetDirect
entity: Entity;
damage?: number;
healing?: number;
buffed?: boolean;
}

export interface OptionCallbackProps {
Expand Down

0 comments on commit 33e0182

Please sign in to comment.