saraaaaras / Redo-YYY-New

0 stars 0 forks source link

Learn better logical coding style #6

Open PCRedHot opened 1 year ago

PCRedHot commented 1 year ago

https://github.com/saraaaaras/Redo-YYY-New/blob/7d2da933fc6a144d62eb12a0f94cc54c3e474cad/Assets/Inport/script/GameEngine.cs#L362

Assume this code is correct logically, it is fine to leave it like that. But there are many other better ways to implement the same logic. For example

eachDiceFaceShownTimes.Max() >= 3
PCRedHot commented 1 year ago

https://github.com/saraaaaras/Redo-YYY-New/blob/7d2da933fc6a144d62eb12a0f94cc54c3e474cad/Assets/Inport/script/GameEngine.cs#L106

Usually, logical statement for boolean should not use == or !=

updatedRolledResultSprite[i] == QuestionMarkSprite  || !diceButton[i].interactable