From 108936324c38565ffa83ab7cf50dd5bd93c7a095 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20R=C3=BCmpelein?= Date: Thu, 23 Oct 2014 16:22:12 +0200 Subject: [PATCH 1/3] Ever-Success implemented --- src/jsds.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/jsds.js b/src/jsds.js index f31d664..5d15749 100644 --- a/src/jsds.js +++ b/src/jsds.js @@ -82,9 +82,16 @@ // Probe-Function: checks, whether a given "effort" is succesfull, according to the rules of DS // Not yet implemented: Tests for values larger than 20 var dice = function(probe) { + console.log(probe); var diceval = Math.floor(Math.random() * (21 - 1)) + 1; if ( diceval <= probe ) { - return diceval; + if (diceval == 1) { + alert ("Immersieg!"); + return probe; + } + else { + return diceval; + }; } else { if (diceval === 20) { @@ -160,7 +167,7 @@ var output=$('#output'); output.html(this.info.cname+" greift "+enem.info.cname+" an!
"); var attack_val = dice(this.battle[this.att]); - if (! attack_val ) { + if (attack_val == 0 ) { output.append('Angriff Fehlgeschlagen!
'); } else { From ce9f06a864de6ad0d449d11925785f23ec64b3f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20R=C3=BCmpelein?= Date: Thu, 23 Oct 2014 17:10:33 +0200 Subject: [PATCH 2/3] Dice-function is complete, this includes: - Test-values larger than 20 - "1" is an ever-success - "20" in first roll is an ultimate failure --- src/jsds.js | 46 ++++++++++++++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/src/jsds.js b/src/jsds.js index 5d15749..58b3196 100644 --- a/src/jsds.js +++ b/src/jsds.js @@ -82,26 +82,40 @@ // Probe-Function: checks, whether a given "effort" is succesfull, according to the rules of DS // Not yet implemented: Tests for values larger than 20 var dice = function(probe) { - console.log(probe); - var diceval = Math.floor(Math.random() * (21 - 1)) + 1; - if ( diceval <= probe ) { - if (diceval == 1) { - alert ("Immersieg!"); - return probe; - } - else { - return diceval; - }; - } - else { - if (diceval === 20) { - alert ("Patzer!"); // We need alert here, because most "Patzer" - // affect gameplay (dropping equipement and so on) - }; + var diceval=new Array(); + var rolls=Math.floor(probe/20)+1; // Player may be allowed to roll the dice several times. + var tvalues=new Array(); + var result=0; + var tmpval; + for(var i=0; i Date: Thu, 23 Oct 2014 17:15:38 +0200 Subject: [PATCH 3/3] branch dice finished --- TODO | 1 - 1 file changed, 1 deletion(-) diff --git a/TODO b/TODO index ef80806..c64d111 100644 --- a/TODO +++ b/TODO @@ -7,7 +7,6 @@ ToDo for JSDSH: - second adventure - add avatars for players and monsters - attack distance - - Testvalues > 20 - Objects: Pass object to initializer - Hitbox on "things" - Instructions-page