From cfabbe44b127c322802967b0c3a84c6aa467a445 Mon Sep 17 00:00:00 2001 From: nihilazo Date: Thu, 18 Mar 2021 11:25:04 +0000 Subject: [PATCH] make chat member power scale with amount of chat members --- main.fs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/main.fs b/main.fs index 38f7777..1c88441 100644 --- a/main.fs +++ b/main.fs @@ -36,9 +36,7 @@ variable membercount \ TODO this is a terrible idea. Potential better ideas: \ * have the change flag be the first value, so then the subsequent values can be any length \ * learn how strings work in this language, store the message inside message - create message 0 , 0 , 0 , - \ set-message sets the message : set-message ( addr len -- ) message ! message 2 cells + ! message changed ; \ get-message gets the message @@ -47,6 +45,10 @@ variable membercount \ set an initial message S" you feel like throwing some stuff into the pool." set-message +\ FOR DEBUGGING PURPOSES - some sets that skip into the future +100 devices ! +10 membercost ! + \ any-change? leaves a -1 on the stack if any value has changed, 0 otherwise : any-change? ( -- flag ) membercost changed? devices changed? message changed? or or ; \ clear-all clears the change flag on all values. @@ -86,7 +88,11 @@ S" you feel like throwing some stuff into the pool." set-message devices @ <= \ tests if the member cost is less than the amount of devices we have and if devices @ membercost @ - devices ! \ remove devices that "pay" for the member - devicerate @ 500 - devicerate ! \ increase the device rate by 500 + membercount @ dup !0= if \ membercount is nonzero + devicerate @ swap 500 swap / - devicerate ! \ decrease the device delay by 500/membercount. TODO There is certainly a more elegent way to do this stack manipulation. + else + devicerate @ 500 - devicerate ! drop + then 1 membercount +! \ add a member to the count membercount @ 2 * 5 + membercost +! \ increase the cost of buying a new member membercost changed