1
0
mirror of https://github.com/ncblakely/GiantsTools synced 2024-11-22 14:15:37 +01:00
GiantsTools/Giants.DataContract/Contracts/V1/ServerInfo.cs

97 lines
2.8 KiB
C#
Raw Normal View History

2020-08-16 11:03:10 +02:00
namespace Giants.DataContract.V1
{
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
public class ServerInfo
{
[Required]
[StringLength(100)]
public string GameName { get; set; }
[Required]
public AppVersion Version { get; set; }
[Required]
[StringLength(100)]
public string SessionName { get; set; }
[Required]
public int Port { get; set; }
[Required]
[StringLength(300)]
public string MapName { get; set; }
[Required]
[StringLength(100)]
public string GameType { get; set; }
[Required]
public int NumPlayers { get; set; }
2020-09-23 23:44:31 +02:00
[Required]
public int MaxPlayers { get; set; }
[Required]
[StringLength(100)]
public string GameState { get; set; }
[Required]
public int TimeLimit { get; set; }
[Required]
public int FragLimit { get; set; }
[Required]
public int TeamFragLimit { get; set; }
[Required]
public bool FirstBaseComplete { get; set; }
[Required]
public IList<PlayerInfo> PlayerInfo { get; set; }
public override bool Equals(object obj)
{
return obj is ServerInfo info &&
this.GameName == info.GameName &&
EqualityComparer<AppVersion>.Default.Equals(this.Version, info.Version) &&
this.SessionName == info.SessionName &&
this.Port == info.Port &&
this.MapName == info.MapName &&
this.GameType == info.GameType &&
this.NumPlayers == info.NumPlayers &&
2020-09-23 23:44:31 +02:00
this.MaxPlayers == info.MaxPlayers &&
this.GameState == info.GameState &&
this.TimeLimit == info.TimeLimit &&
this.FragLimit == info.FragLimit &&
this.TeamFragLimit == info.TeamFragLimit &&
this.FirstBaseComplete == info.FirstBaseComplete &&
this.PlayerInfo.SequenceEqual(info.PlayerInfo);
}
public override int GetHashCode()
{
HashCode hash = new HashCode();
hash.Add(this.GameName);
hash.Add(this.Version);
hash.Add(this.SessionName);
hash.Add(this.Port);
hash.Add(this.MapName);
hash.Add(this.GameType);
hash.Add(this.NumPlayers);
2020-09-23 23:44:31 +02:00
hash.Add(this.MaxPlayers);
hash.Add(this.GameState);
hash.Add(this.TimeLimit);
hash.Add(this.FragLimit);
hash.Add(this.TeamFragLimit);
hash.Add(this.FirstBaseComplete);
hash.Add(this.PlayerInfo);
return hash.ToHashCode();
}
}
}