Terraforming-mars: Some cards start with resources on them randomly

Created on 25 Mar 2020  路  9Comments  路  Source: bafolts/terraforming-mars

Forced Precipation has 1 floater even before played.
90721949_905081343295362_6905203674092404736_n

Rotator Impacts force you to REMOVE one assteroid on Gen 1.
90776823_232631741127119_7577169548277710848_n

The bug was observed with other cards holding floaters and microbes.

E.g. Played Aeriel Mappers round one. Started with 4 floaters on it.

So far, I have experienced the bug only in Solo.

bug

Most helpful comment

I am going to make a card factory that the dealer will use to create each card. There were most likely other bugs we never noticed any time we were using a private property on a class instance to store data.

All 9 comments

I believe there are two different bugs.
Obviously wrong logic in RotatorImpacts action method, and some kind of multiple games on the same server clash in Forced Precipation

I've fixed RotatorImpacts
Resources on cards is magic for me. I can't reproduce it on the localhost.
@bafolts @vincentneko can it be result of initialisation of cards on module level in Dealer.ts
I mean, can different instances of the Game use the same instances of the Card?

Domn... It is reproductible:
1) Add this code in Game constructor to put the same card into player's hand
const venusCards = ALL_VENUS_PROJECTS_CARDS.slice() first.cardsInHand.push(venusCards[12]);
2) Start two solo games with Venus extension enabled
3) In first game: play and activate the Forced Precipitation card to have resources on it
4) In second game: refresh the page and you will see unwanted resources on the Forced Precipitation card

This is a critical bug: "different instances of the Game use the same instances of the Card"

Another case:
Game 1: The player with Aridor played tags and got production as expected.
Game 2: The player with Aridor played Jovian and Space tags, but got nothing, because in another ongoing game (Game1), Aridor already has those tags played. The Science tag gave 1 production as expected, because it is not played in Game1.
games

There was a recent change which moved the logic for tracking resources on a card from the game to the instances of the cards themselves. The dealer is providing different games the same instance of the card now as @alrusdi suggested. The change will need to be reverted or the dealer will have to provide new instances of the cards to players.

Or we can store resources on card in game_id -> resource_count map. But it is, probably, not the solution. We should implement separate card instances for each game. Any ideas about implementation?

I am going to make a card factory that the dealer will use to create each card. There were most likely other bugs we never noticed any time we were using a private property on a class instance to store data.

I put up a pull request to fix this. I have the card factories in place but need to finish up the tedious task of porting the remaining cards to the factory syntax. For the time being if you re-start the game server between each game you can avoid these issues. We have a few cards where we store or used to store data specific to that card. This should fix issues we never noticed with those cards as well. I will finish up the mapping to the card factory syntax by the end of the day unless someone beats me to it. The pattern is in place on the pull request if someone wants to finish the work.

This is fixed now. Thanks to @bafolts for great work on it!

Was this page helpful?
0 / 5 - 0 ratings