How can I setup a rule to validate the winner(s)?

yuttuy3yuttuy3 Member, PRO Posts: 17
edited May 2015 in Working with GS (PC)

I'm creating a multiplayer game. But I can't seem to figure out how to validate the winner(s).

The case:

  • Multiplayer game with up to 4 players.
  • Player with the highest score will be anounced as the winner.

The tricky part:

  • Scores can be the same.
  • Sometimes there can be one, two, three or even four winners.

Anyone got an idea how to setup a rule to figure out which player(s) will be getting a medal?

Best Answer

  • OscarsCodingOscarsCoding Posts: 92
    Accepted Answer

    just make a bunch of rules checking each possible outcome, it may be time consuming, but it works!

Answers

  • yuttuy3yuttuy3 Member, PRO Posts: 17

    Is this the only way?
    If I'm correct, i would have 15 possible outcomes.
    That's a lot of rules for one function.

  • yuttuy3yuttuy3 Member, PRO Posts: 17

    Not the answer i hoped for, but i went ahead and made xx rules for each outcome to make it work.

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited May 2015

    If attribute game.player1Score = max(game.player1Score, game.player2Score, game.player3Score, game.player4Score) then
         Change Attribute game.winningPlayer (text) to "Player 1"

    If attribute game.player2Score = max(game.player1Score, game.player2Score, game.player3Score, game.player4Score) then
         Change Attribute game.winningPlayer (text) to "Player 2"

    If attribute game.player3Score = max(game.player1Score, game.player2Score, game.player3Score, game.player4Score) then
         Change Attribute game.winningPlayer (text) to "Player 3"

    If attribute game.player4Score = max(game.player1Score, game.player2Score, game.player3Score, game.player4Score) then
         Change Attribute game.winningPlayer (text) to "Player 4"

    You'll have to decide what to do in the case of ties. You might want to use booleans for each player's win outcome (game.player1Wins) instead of text attributes, for example, and then display a message/medal based on the value of each boolean.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

Sign In or Register to comment.