Open iPoetDev opened 10 months ago
Sprint: 03: Ends 23-01-07 Bump: Previous: 23-01-06 v00.00.03.003 Changelog: 23-01-07 v00.00.03.004
Sprint: 03: Ends 23-01-07 Bump: Previous: 23-01-06 v00.00.03.003 Changelog: 23-01-07 v00.00.03.004
feat/fix (App): Update/Refactor GameLogic from App class.
Intent: Update the UI dynamically when underlying array updates. Issue: Fixed: ToDo:
Sprint: 03: Ends 23-01-07 Bump: Previous: 23-01-06 v00.00.03.003 Changelog: 23-01-07 v00.00.03.004
feat/fix (App): Update/Refactor GameLogic from App class. Intent: Alpha class design, JSDoc, code layout and Webstorm inspections Issue: Fixed: Files: game.html, game.js (same class def)
ToDo:
typeof
checks for parameter primitivesgame.js
, using per file defintionsBranch: fix/game-app-001
CODE
:Related
Feature
]() ::User Story
]() ::UAC
]() ::Previous
Design: GameLogic() class.
Decisions
App()
toGameLogic()
ClassName.CONSTANT_NAME
as declaration.GameLogic.CONTANT_NAME
constructor()
andreset()
primarily,Changelog
Class API
this._member
1. Constructor
2. Class | Instance Members
_
as convention, not by syntax.this.DEBUG
boolean
}false
false
,true
}this.LEVEL
number
}0
0
,1
,2
,3
,4
,5
,6
}this._EMPTYCELL
null
}null
GameLogic.CELL_RESET
null
this._turns
number
}0
GameLogic.TURN_INIT
n<=8
this._currentcell
string
}GameLogic.CELL_RESET
`,
X,
O`this._draw
boolean
}false
GameLogic.NO_DRAW
false
,true
}this._won
boolean
,string
}false
GameLogic.IN_PLAY
false
,X
,O
}this._winSeq
array
}string
>GameLogic.WIN_COMBINATIONS
GameLogic.WIN_COMBINATIONS
this._grid
array
}null
|string
>GameLogic.NEW_GRID
null
,X
,O
this._xChars
array
}string
>[x,X]
this._oChars
array
}string
>[o,O]
this._xTurns
string
}._xTurn
GameLogic.X_TURN_PROP
.xTurn
this._oTurns
string
}._oTurn
GameLogic.O_TURN_PROP
.oTurn
3. Class Properties (Getters/Setters)
Extensive Use Cases
Getters/Setters to manage
Class Constants give name/use case to the raw values explicitly, and not implicit meaning, use or context.
this.DEVMODE
Default Value
this.LOGLEVEL
Default Value
GameLogic.P1
Default Value
X
GameLogic.P2
Default Value
O
GameLogic.P1_TOKENS
X
orx
: A design choice for variability in token font/display based on font choiceGameLogic.P2_TOKENS
O
oro
GameLogic.REG_SEARCH_LENGTH
Default Value
3
GameLogic.REG_SEARCH_ALL
Default Value
g
GameLogic.REG_SEARCH_FILTER
Default Value
GameLogic.WIN_COMBINATIONS
Default Value
GameLogic.AS_DRAW
Default Value
true
Default Value
false
GameLoic.CELL_RESET
Default Value
null
GameLogic.MAX_LENGTH
Default Value
9
GameLogic.TURN_RESET
Default Value
' '
GameLogic.TURN_INIT
Default Value
' '
GameLogic.X_TURNS_PROP
Default Value
'._xTurns'
GameLogic.O_TURNS_PROP
Default Value
'._oTurns'
this.WIN_SEQUENCE
As-Is Value
this.GRID
As-Is Value
this.NEW_GRID
As-Is Value
MAX_LENGTH
,CELL_RESET
this.IFWON
As-Is Value
false
, per turn is false for next round, or ends as:X
vO
this.IFDRAWN
As-Is Value
false
, end state:true
this.TURNS
As-Is Value
this.MAX_TURNS
As-Is Value
MAX_LENGTH - 1
this.CELL
As-Is Value
X
orO
this.currentCell(index)
Computed Value
*
4. Class General Helpers/Debug
this._console
5.
select()
and Helper Functions_getRandomCharacter
_updateTurnsAndGrid
_getRandomIndex
_updateTurnsAndGrid
_isEvenTurn
_isInvalidMove
select
_isEvenTurn
select
_isTurnEven
_chooseChar
_selectProp
_incrementTurn
select
select
_whoWins
,_whoDraws
,_hasValidMove
,Object <anon><br> cell, next \|\| endstate, message, state, valid, outcome
6.1
checkWinner
and Helper Functions_checkSequenceWin
checkWinner
checkWinner
6.2
checkWinningPlay
and Helper Functions_checkSequenceWin
checkWinner
checkWinninPlay
_assignWinner
_defaultRound
...
7.
reset
reset