From f920e29c9959175881761637d4b7d06ce952b555 Mon Sep 17 00:00:00 2001 From: b Date: Tue, 6 Apr 2021 14:53:24 -0700 Subject: [PATCH] Allow boolean to be interpreted as numeric 1 --- query_2.js | 7 +++++++ testing/ms_simulator.py | 22 +++++++++++++--------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/query_2.js b/query_2.js index d81de10..878b5a4 100644 --- a/query_2.js +++ b/query_2.js @@ -5,6 +5,10 @@ function checkBool(v) { } function checkNum(v) { + if (typeof v === 'boolean') { + if (v) return 1; + return 0; + } if (typeof v !== 'number') throw new Error(`Expected number, but got ${typeof v}`); return v; } @@ -261,6 +265,9 @@ function staticCheck(expType, term) { if (expType === 'any' || expType === term.type) { return true; } + if (expType === 'number' && term.type === 'boolean') { + return true; + } throw new Error(`Expected ${expType}, but got ${term.type}`); } diff --git a/testing/ms_simulator.py b/testing/ms_simulator.py index cafc08d..22e7024 100644 --- a/testing/ms_simulator.py +++ b/testing/ms_simulator.py @@ -3,19 +3,23 @@ realSpeeds = [] # TODO atkSpd = 6 -#spellCycle = [1, 2, 1, 2, 0] -#spellDelay = [0.5, 0.5, 0.5, 0.5, 0] -spellCycle = [-1, 1, 0, 2, 1, 1] -spellDelay = [0.4312345, 0, 0.4, 0.4, 0.4, 0.4] +#spellCycle = [1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 2, 2] +#spellDelay = [0.5, 0, 0.5, 0.5, 0, 0.5, 0.5, 0, 0.5, 0.5, 0, 0.5, 0.5, 0, 0.5, 0.5, 0, 0.5, 1, 0.5] +spellCycle = [1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2] +spellDelay = [0.5, 0, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 1, 0.5] +#spellCycle = [-1, 1, 0, 2, 1, 1] +#spellDelay = [0.4312345, 0, 0.4, 0.4, 0.4, 0.4] #spellCycle = [9, 0, 9, 0, 10, 0, 0] #spellDelay = [0, 1.4, 0, 1.4, 0, 1.3, 1.3] -delayCycle = [1.2, 0, 0.4, 0.4, 0.4, 0.4] -spellCycle = spellCycle*8 -spellDelay = spellDelay*4 + delayCycle + spellDelay*2 + delayCycle +#delayCycle = [1.2, 0, 0.4, 0.4, 0.4, 0.4] +#spellCycle = spellCycle*8 +#spellDelay = spellDelay*4 + delayCycle + spellDelay*2 + delayCycle simulation_end = 100 -manaRegens = [5, 0, 15] -manaSteals = [9, 13, 0] +#manaRegens = [5, 0, 15] +#manaSteals = [9, 13, 0] +manaRegens = [0, 0] +manaSteals = [8, 11] import random import math