Skip to content

Commit 17664ae

Browse files
committed
Added "bonusToLonger".
1 parent 40bac6b commit 17664ae

3 files changed

Lines changed: 33 additions & 1 deletion

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,6 @@ Note that `eatables.apple` can either be `null` or a number. The number only rep
2929
| `rules` | `apples` | How many apples is located at the arena and how they are placed. |
3030
| `rules` | `defeatedWorms` | What will happen to a defeated worm.<br>• `Disappears`<br>Defeated worms are removed.<br>• `Eatable`<br>Defeated worms becomes eatable for extra points.<br>• `Solid`<br>Defeated worms turns into a wall. |
3131
| `rules` | `winner` |`LastWormStanding`<br>Participants that are alive receive one point each time a worm is defeated. <br>• `MostPoints`<br>Participants receive one point for every eaten object until there is no more worms alive.|
32+
| `rules` | `bonusToLonger` | If two worms score equal, bonus point is dealt to the longer worm. |
3233

3334
To keep the challenge for all worms to be symmetric and equal, make sure to keep the amount of teams to an even number.

arena.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,35 @@ function tick(){
589589
if((_settings.rules.winner === 'LastWormStanding' ? 1 : 0) < _worms.length){
590590
tick();
591591
}else{
592+
if(_settings.rules.winner === 'LastWormStanding' && _settings.rules.bonusToLonger){
593+
let list = [];
594+
let maxLength = -1;
595+
while(list.length < _participants.countTeams()){
596+
let participant = _participants.get(list.length, 0);
597+
let wormLength = participant.payload.worm.getLength();
598+
maxLength = Math.max(maxLength, wormLength);
599+
list.push({
600+
participant: participant,
601+
wormLength: wormLength,
602+
score: null
603+
});
604+
}
605+
maxLength *= 10;
606+
_participants.getScores().forEach(s => {
607+
list[s.team].score = s.score;
608+
});
609+
let bonusPoint = 0;
610+
let lastScore = null;
611+
let lastLength = null;
612+
list.sort((s1, s2) => (s1.score - s2.score)*maxLength + (s1.wormLength - s2.wormLength)).forEach(s => {
613+
if(lastScore === s.score && lastLength != s.wormLength){
614+
bonusPoint++;
615+
}
616+
s.participant.addScore(bonusPoint);
617+
lastScore = s.score;
618+
lastLength = s.wormLength;
619+
});
620+
}
592621
ArenaHelper.log('tick', parseArena());
593622
ArenaHelper.postDone();
594623
}

properties.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,13 @@
3030
"apples": ["AppleLess", "Single", "FourSymmetry", "FourRandom_asymmetric", "OneRandomPerWorm_asymmetric"],
3131
"defeatedWorms": ["Disappears", "Eatable", "Solid"],
3232
"winner": ["LastWormStanding", "MostPoints"],
33+
"bonusToLonger": false,
3334
"_meta": {
3435
"startLength": {"min": 1, "max": null, "step": 1},
3536
"apples": {"default": "FourSymmetry", "comment": {"message": "<b>AppleLess:</b><br>Sets rules.startLength to infinity and border.movesPerArenaShrink to -1.<br><b>FourSymmetry:</b><br>When one is eaten, all get renewed.<br><b>FourRandom_asymmetric:</b><br>When one is eaten, all get renewed.<br><b>OneRandomPerWorm_asymmetric:</b><br>When one is eaten, only it get renewed."}},
3637
"defeatedWorms": {"default": "Eatable"},
37-
"winner": {"default": "LastWormStanding", "comment": {"message": "<b>Note:</b><br><i>MostPoints</i> is locked to <code>defeatedWorms:Solid</code>, due to otherwise last standing worm could play safe and collect eatables once its' opponents are gone."}}
38+
"winner": {"default": "LastWormStanding", "comment": {"message": "<b>Note:</b><br><i>MostPoints</i> is locked to <code>defeatedWorms:Solid</code>, due to otherwise last standing worm could play safe and collect eatables once its' opponents are gone."}},
39+
"bonusToLonger": {"comment": {"message": "If two worms score equal, bonus point is dealt to the longer worm."}}
3840
}
3941
}
4042
}

0 commit comments

Comments
 (0)