Coding test

A snippet of code to test a “gambit” system where players who fail a check can get a second chance at succeeding by relying on a little bit of luck.

Link to demo code: Gambit failure test (

Have a little play (it’s really short and extremely simple for the point of the test. Your choices in the fight are related to the stats as shown below.

Sword = Attack
Shield = Defend
Spell = Magic

If you either draw or lose you will get an extra option to roll a dice which does the check again but with a possible boost (it is currently set as *rand 0 2)

Thoughts on this gambit system would be appreciated would you like to see this in an actual game or not?


I think it’s a cool system but would probably prefer it not appear in a game. In general, I’m not a big fan of core mechanics of a choice game relying on chance. I feel it takes away some of the agency one gains through their choices.

By the way, if I hit “Play again.” it returns errors but then lets me carry on.

1 Like

I noticed the error too but it plays fine and passed quicktest and randomtest which is very odd.

I can see the point of it taking agency away but as it is an optional choice I’m not sure if it would take away a lot of agency.

I was just thinking of times players miss a check by a couple of points. Can be quite annoying.

1 Like

True, it could be a good system that can be turned on or off at the start or through the stat screen.

In the coded demo it is a choice that asks if you want to accept your fate. Which for the short test works okay.

If I added it to a proper game I might limit the number of times to say you can do it twice per chapter so players have to think about if its worth the risk. Also I wouldn’t use it in a game that has proper death in it so even if you lose and accept it you aren’t completely punished for it.

1 Like

It’s a cool idea. Disco Elysium has a similar system I was thinking of replicating for my own game, where if you fail certain checks you can try again if you boost the relevant stat. So like yours, but instead of a random boost you have to improve that skill through levelling/items/gameplay.

I imagine this would be used as a limited resource, in a game? Ex. only a certain number of gambits per playthrough.

Yes. For the game I’d use it for. You would be able to use 2 gambits per chapter.

I also would have gambit successes result in different scenes.

For example let’s say there is a swordfight between the MC.

If the MC has swordplay of 3 which passes the check. They disarm their opponent.

But if the MC only has 2 swordplay they would lose. They over extend and they lose their balance letting their opponent win.

Now this time they can use a gambit if they succeed their opponent trips when they try to attack allowing the player to recover and win the encounter

1 Like

I made one attack and won the whole game. Then it crashed.


1 Like

Yeah the code is literally a single choice (two if you draw or are about to lose)

Just to show the concept.

That error is a strange one as the code doesn’t error with quicktest or randomtest.