-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: Implement Basic Stats #9
base: master
Are you sure you want to change the base?
Changes from all commits
3c7e2bd
99a85a3
aab67fc
9ce7935
736fb22
8f6f2ec
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,6 +1,5 @@ | ||||||
'use strict'; | ||||||
|
||||||
// TODO have Entity inherit from Fabric.Vector | ||||||
const crypto = require('crypto'); | ||||||
|
||||||
function Entity (entity) { | ||||||
|
@@ -10,16 +9,39 @@ function Entity (entity) { | |||||
this.type = entity.type || 'Unknown'; | ||||||
this.name = entity.name || this.id; | ||||||
|
||||||
this.experience = 0; | ||||||
this.EXP = 0; | ||||||
this.statPoints = 15; | ||||||
|
||||||
this.equipment = { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Scanned over the rest of the file; is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Didn't intend to remove equipment completely, that may have been something I was trying to accomplish but meant to undo. |
||||||
armor: null, | ||||||
weapon: null | ||||||
this.stats = { | ||||||
attack: 0, | ||||||
agility: 0, | ||||||
vitality: 0, | ||||||
invocation: 0, | ||||||
influence: 0, | ||||||
shielding: 0, | ||||||
smarts: 0, | ||||||
willpower: 0, | ||||||
charm: 0 | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Whoa, that's a lot of different stats! Let's coordinate out-of-band to go over the player experience. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's potential for slimming the amount down. Or at least subdividing them to make them reader-friendly (original subdivisions were |
||||||
}; | ||||||
|
||||||
this.stats = { | ||||||
strength: 0, | ||||||
luck: 0 | ||||||
this.derrivedStats = { | ||||||
damage: 0, | ||||||
hp: 0, | ||||||
mDamage: 0, | ||||||
enchantments: 0, | ||||||
mHP: 0, | ||||||
library: 0, | ||||||
ap: 0, | ||||||
summons: 0 | ||||||
}; | ||||||
|
||||||
this.cardLibrary = { | ||||||
attackCards: 0, | ||||||
itemCards: 0, | ||||||
summonCards: 0, | ||||||
spellCards: 0, | ||||||
enchantCards: 0, | ||||||
leylineCards: 0 | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These two new properties seem like they should be simplified and variable names thought about a bit more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Those are meant to be "maximum" variables, so the names should likely be changed to represent this, or they should be condensed -- or maximums removed entirely. Not sure. |
||||||
}; | ||||||
|
||||||
this.effects = {}; | ||||||
|
@@ -29,29 +51,66 @@ function Entity (entity) { | |||||
return this; | ||||||
} | ||||||
|
||||||
Object.defineProperty(Entity.prototype, 'level', { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This has to stick around, as it's used elsewhere. |
||||||
get: function level () { | ||||||
if (this.experience) { | ||||||
return Math.floor(Math.log(this.experience / 10)); | ||||||
} else { | ||||||
return 0; | ||||||
} | ||||||
Object.defineProperty(Entity.prototype, 'attack', { | ||||||
get: function attack () { | ||||||
Entity.derrivedStats.damage = Entity.stats.attack; | ||||||
|
||||||
return Entity.stats.attack; | ||||||
} | ||||||
}); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You don't need to use
Suggested change
If you're just looking for the raw statistic, you can remove these entirely. |
||||||
|
||||||
Object.defineProperty(Entity.prototype, 'agility', { | ||||||
get: function agility () { | ||||||
return Entity.stats.agility; | ||||||
} | ||||||
}); | ||||||
|
||||||
Object.defineProperty(Entity.prototype, 'vitality', { | ||||||
get: function vitality () { | ||||||
Entity.derrivedStats.hp = (Entity.stats.vitality * 10); | ||||||
return this.stats.vitality; | ||||||
} | ||||||
}); | ||||||
|
||||||
Object.defineProperty(Entity.prototype, 'invocation', { | ||||||
get: function invocation () { | ||||||
Entity.derrivedStats.mDamage = Entity.stats.invocation; | ||||||
return this.stats.invocation; | ||||||
} | ||||||
}); | ||||||
|
||||||
Object.defineProperty(Entity.prototype, 'influence', { | ||||||
get: function influence () { | ||||||
Entity.derrivedStats.enchantments = 1 + (Entity.stats.influence); | ||||||
return this.stats.influence; | ||||||
} | ||||||
}); | ||||||
|
||||||
Object.defineProperty(Entity.prototype, 'shielding', { | ||||||
get: function shielding () { | ||||||
Entity.derrivedStats.mhp = 1 + ((Entity.stats.shielding) * 5); | ||||||
return this.stats.shielding; | ||||||
} | ||||||
}); | ||||||
|
||||||
Object.defineProperty(Entity.prototype, 'smarts', { | ||||||
get: function smarts () { | ||||||
Entity.derrivedStats.library = 10 + ((Entity.stats.smarts) * 5); | ||||||
return this.stats.smarts; | ||||||
} | ||||||
}); | ||||||
|
||||||
Object.defineProperty(Entity.prototype, 'strength', { | ||||||
get: function strength () { | ||||||
return this.stats.strength; | ||||||
Object.defineProperty(Entity.prototype, 'willpower', { | ||||||
get: function willpower () { | ||||||
Entity.derrivedStats.ap = 1 + Entity.stats.willpower; | ||||||
return this.stats.willpower; | ||||||
} | ||||||
}); | ||||||
|
||||||
Object.defineProperty(Entity.prototype, 'luck', { | ||||||
get: function luck () { | ||||||
if (this.effects && this.effects.blessed) { | ||||||
return this.stats.luck * 2; | ||||||
} else { | ||||||
return this.stats.luck; | ||||||
} | ||||||
Object.defineProperty(Entity.prototype, 'charm', { | ||||||
get: function charm () { | ||||||
Entity.derrivedStats.summons = 1 + Entity.stats.charm; | ||||||
return this.stats.charm; | ||||||
} | ||||||
}); | ||||||
|
||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid changing the name of properties on templates, since other parts of the program most likely depend on them. Also, as a general rule, try to keep all properties human-friendly — there's no need to shorten variable names in modern languages!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it, I'll change it back to
this.experience