#3477 closed enhancement (fixed)
[PATCH] Add a meta-cheat to abbreviate others
Reported by: | elexis | Owned by: | elexis |
---|---|---|---|
Priority: | Nice to Have | Milestone: | Alpha 20 |
Component: | UI & Simulation | Keywords: | patch |
Cc: | Patch: |
Description
When doing test-games with cheats enabled, you have to type many sentences in order to activate all required cheats. If you have to repeat this process a couple of times (for example when reproducing a given bug) it becomes annoying quickly.
The usual cheats are:
- "the hive master" (full population capacity)
- "i am too busy" (build structures fast)
- 2x "back to the future" (advance phase)
A new cheat could be introduced that acts as an abbreviation for those three cheats. It would make some sense to add the following cheats too, if we introduce such a meta-cheat:
- i want pizza 100000 (add resources: food)
- bring me my axe 100000 (add resources: wood)
- your money or your life 100000 (add resources: metal)
- i see a mountain here 100000 (add resources: stone)
- TARDIS (500 population capacity)
This way you would have the additional benefit of not having to start with deathmatch resources.
Attachments (3)
Change History (11)
by , 9 years ago
Attachment: | ticket3477_metacheat.diff added |
---|
comment:1 by , 9 years ago
Keywords: | patch review added |
---|---|
Milestone: | Backlog → Alpha 20 |
Summary: | Add a meta-cheat to abbreviate others → [PATCH] Add a meta-cheat to abbreviate others |
follow-up: 3 comment:2 by , 9 years ago
Looks good to me and it could probably be committed like that. The code could be simplified a bit more though:
AddResource
:- Why have a
type
variable if you can just use the strings directly as the function argument? - using
input.parameter
as the second argument is good, but you could just add DefaultParameter to the JSON file instead of defining it in the javascript. Makes it a bit cleaner and the user could also change that value. (Also add theIsNumeric
property then)
- Why have a
- To further improve the style: Instead of manipulating the existing
input
object, use the cheat function likeCheat({ "action": "maxpopulation" });
Notice the whitespace (see @wiki:Coding_Conventions) - The early returns are good
Thank you for working on this! :)
comment:3 by , 9 years ago
- To further improve the style: Instead of manipulating the existing
input
object, use the cheat function likeCheat({ "action": "maxpopulation" });
Changed the other things in my local version but when I change the statement above, I get crashes in the checks above the switch in "Cheat.js" when executing the function.
WARNING: JavaScript warning: simulation/helpers/Cheat.js line 4 reference to undefined property input.player
Probably because the "input" structure is not fully in the argument. So the "input.player" is not defined.
Notice the whitespace (see @wiki:Coding_Conventions)
Checked the code in "Cheat.js" on this and improved it :)
comment:4 by , 9 years ago
Right, you will need to pass the "player" attribute too (maybe others too, didn't look at it), i.e.
Cheat({ "player": input.player, "action": "maxpopulation" });
(I think you could replace the calls to AddResources
with a calls to Cheat
too. Would be a bit more coherent, but that's not really needed)
comment:5 by , 9 years ago
Thanks for the cleanup, the existing code and your new code look even better than before.
case "addresource":
I think we can remove the for-loop andtext.input
change, not used, only one resource will be added.case "metacheat":
wrong indentationCheat
: misssing semicolons
comment:7 by , 8 years ago
Keywords: | review removed |
---|
Thanks for the patch! :-) I removed some of the comments as the code should be clear enough already, one space after a return and one tab before 'case "metaCheat":'. Also I used a loop so we don't repeat code.
Working patch, implenting a metacheat "gift from the gods". Using exsisting functions (could change to direct cheating) and a loop around the resources might be needed.