Skip to content

Commit

Permalink
tidier.
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisforbes committed Apr 13, 2010
1 parent 9e11932 commit 6cf4692
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions OpenRA.Game/Widgets/PostGameWidget.cs
Expand Up @@ -9,31 +9,22 @@ namespace OpenRA.Widgets
{
class PostGameWidget : Widget
{
string text;

public override void Draw(World world)
{
base.Draw(world);

if (world.LocalPlayer == null) text = null;
if (world.LocalPlayer == null) return;

else if (world.players.Count > 2) /* more than just us + neutral */
if (world.players.Count > 2) /* more than just us + neutral */
{
var conds = world.Queries.WithTrait<IVictoryConditions>()
.Where(c => c.Actor.Owner != world.NeutralPlayer);

if (conds.Any(c => c.Actor.Owner == world.LocalPlayer && c.Trait.HasLost))
text = "YOU ARE DEFEATED";
DrawText("YOU ARE DEFEATED");
else if (conds.All(c => c.Actor.Owner == world.LocalPlayer || c.Trait.HasLost))
text = "YOU ARE VICTORIOUS";
else
text = null;
DrawText("YOU ARE VICTORIOUS");
}
else
text = null;

if (text != null)
DrawText(text);
}

void DrawText(string s)
Expand Down

0 comments on commit 6cf4692

Please sign in to comment.