oop - Javascript variable value doesn't update the way it should -
oop - Javascript variable value doesn't update the way it should -
i'm refactoring black jack card game wrote in javascript while back. original version written procedurally , looked amateurish redoing oop style -- first time i've ever tried write oop. i've included link excerpt of code doesn't seem working. i've included pertinent code because whole script hundreds of lines long.
essentially, have prototype called betting contains wager-based functions need game. have prototype called gameui registers click events in game -- actions 'deal', 'hit', stay, wagers, etc ...
please @ function wrote in betting called updatewager(). created , called in gameui.wagerevents(). can't value of this.playerwager ever initial value of zero. know there's nil wrong with:
this.playerwager += parseint(value, 10); because worked in previous version of code, , i've gotten work in code using global scope on variable assignment, , don't want that, obviously. help can figure out amazing.
thanks!
http://jsbin.com/nokim/1/edit
@aravind, right except gameui betting reference needed syntax tweaked.
function gameui(){ //var betobj = new betting(); this.betobj = new betting(); // should instead this.registerdomelements(); this.registerwagerevents(); this.registerdealbuttonevent(); this.registerhitbuttonevent(); this.registerstaybuttonevent(); betobj.renderstartingtotalcash(); } javascript oop
Comments
Post a Comment