123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165 |
- var stances = ["attack", "full attack", "defense", "full defense", "center"];
-
- const mechanics = new Array();
- // [ school name ][ mechanic name ][ action ][ function ]
- mechanics[ "œil de l'aigle" ] = { name : "kiho",
- action : ()=> {
- console.log("En restant immobile et concentré, læ moine peut peut voir à un nombre de milles égal à son rang d'école, avec assez de précision pour reconnaître des individus, mais pas assez pour lire.");
- }
- };
- mechanics[ "moine hitomi" ] = { name : "don de la dame",
- mutator : ( charac ) => {
- charac['getTN'] = () => { return charac.defaultGetTN() + charac.reflexes;}
- addTatoo( charac );
- }
- };
- mechanics[ "moine hitomi" ] = { name : "frapper la base",
- mutator : ( charac ) => {
- charac['getTN'] = () => { return charac.defaultGetTN() + charac.reflexes;}
- }
- };
- mechanics[ "moine hitomi" ] = { name : "déplacer le vent",
- mutator : ( charac ) => {
- charac[ 'actions' ][ 'unarmed attack' ].actionType = 'simple';
- charac.chooseTatoo();
- }
- };
-
- class Characters {
- constructor(){};
-
- pool = [];
- elements = ["Character", "Samourai", "People"];
-
- at( index ){
- return this.pool[ index ];
- }
-
- elementsType = Character;
-
- create( json ){
- let charac = new Character();
-
- if( typeof json === "Object" )
- charac.fromJson( json ) ;
-
- this.add( charac );
- }
-
- createCharacter( aRole, gender, name, familly,experience, gempukku, skills ){
- let character = new Character( aRole, gender, name, familly, school, experience, gempukku, skills );
- this.add( character );
- }
-
- createSamourai( aRole, gender, name, familly, school, experience, gempukku, skills ){
- let samourai = new Samourai( aRole, gender, name, familly, school, experience, gempukku, skills );
- this.add( samourai );
- }
-
- createPeople( gender, name, familly, school, experience, skills ){
- let people = new People( gender, name, familly, school, experience, skills );
- this.add( people );
- }
-
- fromJson( json ){
-
- let data = JSON.parse(json);
-
- for( prop in data){
- this[ prop ] = data[ prop ];
- }
- }
-
- /** add
- * character, parameter, must be declare in the characters.elemets.list
- * return boolean
- **/
- add(character){
- if( this.elements.includes( character.constructor.name )){
- this.pool.push( character );
- return true;
- }else{
- return false;
- }
- }
-
- indexOf( character ){
- if( this.elements.includes( character.constructor.name )){
- for(let i = 0; i < this.pool.length ; i++){
- if( character == this.pool[ i ] )
- return i;
- }
- }
- }
-
- getByName( name ){
- for(let i = 0; i < this.pool.length ; i++){
- if( this.pool[i].getName() == name)
- return this.pool[i];
- }
- }
-
- getIndexByName( name ){
- for(let i = 0; i < this.pool.length ; i++){
- if( this.pool[i].getName() == name)
- return i;
- }
- }
-
- size(){
- return this.pool.length;
- }
- }
-
-
- var RNG = new RandomGenerator(4);
-
- function characterFromJSON( json ){
- let result = new Character();
- let data = JSON.parse(json);
-
- for( prop in data){
- result[ prop ] = data[ prop ];
- }
-
- return result;
- }
-
- function fight(charac1, charac2){
- let result = {
- "attacker" : charac1.initiative(),
- "defender" : charac2.initiative()
- };
- let first = ( charac1.initiative() + (charac1.water/10) > charac1.initiative() + (charac1.water()/10))? charac1 : charac2 ;
- let second = ( charac1 == first)? charac2 : charac1 ;
- let winner = 0
- let round = 0;
-
- while( !winner ){
- round++;
-
- result[round] = {
- "attack" : {
- "attacker" : first.attack(),
- "defender" : second.attack()
- },
- "damage" : {
- "attacker" : first.damage(),
- "defender" : second.damage()
- }
- };
- result[round]["wounds"] = {
- "attacker" : ( result[round]['attack']['attacker'] >= second.getTN() )? second.getWounded( result[round]['damage']['attacker'] ) : 0,
- "defender" : (( result[round]['attack']['defender'] >= first.getTN() ) && second.malus < 100)? first.getWounded( result[round]['damage']['defender'] ) : 0,
- }
-
- if( second.malus > 99 ){
- winner = first;
- } else if( first.malus > 99 )
- winner = second;
- }
-
- result['winner'] = winner ;
- result['winner_side'] = (winner == charac1)? "attacker": "defender";
- return result;
- }
|