Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#4010 closed defect (fixed)

[PATCH] Wonder victory messages need to be deleted after win

Reported by: elexis Owned by: Itms
Priority: Should Have Milestone: Alpha 21
Component: UI & Simulation Keywords: patch
Cc: Patch:

Description

When someone wins a wonder victory game and an ally owns a wonder too, the message that he will win too should disappear (as only one player / team can win the game).

Furthermore building a new one shouldn't result in triggering the countdown again.

See EndGameManager.js and WonderVictory.js.

Attachments (4)

wondervictorymessagesfix.patch (1.7 KB ) - added by Sandarac 8 years ago.
There's probably a better way to do this.
wondervictorymessagesfix_v2.patch (3.9 KB ) - added by Sandarac 8 years ago.
wondervictorymessagesfix_v3.patch (2.3 KB ) - added by Sandarac 8 years ago.
wondervictorymessagesfix_v4.patch (2.3 KB ) - added by Sandarac 8 years ago.
Also adds "PlayerWon" and "PlayerDefeated" as Trigger events, after discussion with elexis.

Download all attachments as: .zip

Change History (13)

by Sandarac, 8 years ago

There's probably a better way to do this.

comment:1 by Sandarac, 8 years ago

Keywords: review patch added
Milestone: BacklogAlpha 21
Summary: Wonder victory messages need to be deleted after win[PATCH] Wonder victory messages need to be deleted after win

comment:2 by elexis, 8 years ago

Keywords: review removed
  • Your patches are produced with windows line endings. Not sure if you can change that somehow, but it needs to be fixed everytime when applying / committing.
  • The keys of wonderVictoryMessages are entities, not messages. A for ... of loop makes it a bit shorter.
  • Since you don't need cmpPlayerManager nor numPlayers, the new code should have been added above those 2 lines.
  • Since you delete wonderVictoryMessages, move that code to the file that contains those, i.e. WonderVictory.js.
  • You also need to delete the timer that triggers the winning once a player won. You can likely just move line 8-19 of WonderVictory.js to a new function and reuse that.
  • Wonder games can also be won by wiping out an enemy, so better check that on player defeat. MarkPlayerAsWon is only called from SetPlayerWon which is only called from some maps and wonder victory. The code should likely contain also a message OnPlayerWon for consistency. For the time being, you can most likely use the AlliedVictoryCheck.

by Sandarac, 8 years ago

comment:3 by Sandarac, 8 years ago

Keywords: review added

comment:4 by elexis, 8 years ago

Keywords: review removed
  • The "won" message was finally introduced in r18441.
  • Inconsistent use of let/var.
  • Use this.messages and timers instead of the QueryInterface
  • OnPlayerWon = true whut?
  • The Trigger.js change doesn't look like it is needed to make it work

by Sandarac, 8 years ago

comment:5 by Sandarac, 8 years ago

Keywords: review added

comment:6 by elexis, 8 years ago

Thanks for the update, that's nearly ready to commit:

  • QueryPlayerIDInterface instead of L32+33
  • Use this.wonderVictoryMessages and this.wonderVictoryTimers directly instead of a new variable
  • message should be ent or entity
  • Keep the components independent of each other. The EndGameManager should have no clue of stuff inside WonderVictory. Move that code to that file.
  • If you read the code, wonderVictoryMessages nor wonderVictoryMessages can become false/undefined/null, so those checks are pointless.
  • There is a timer if and only if there is a message, so you can merge those two loops.

by Sandarac, 8 years ago

Also adds "PlayerWon" and "PlayerDefeated" as Trigger events, after discussion with elexis.

comment:7 by Itms, 8 years ago

Owner: set to Itms
Resolution: fixed
Status: newclosed

In 18514:

Properly handle wonder victory messages after a player has won.

Patch by Sandarac, reviewed by elexis, fixes #4010

comment:8 by Itms, 8 years ago

Keywords: simple review removed

Thanks for this patch! :D

comment:9 by Itms, 8 years ago

A little oversight though: r18515

Note: See TracTickets for help on using tickets.