public Tribesman(ITribe tribe, IPlayer player, DateTime joinDate, Resource contribution, ITribeRank rank) { Tribe = tribe; Player = player; JoinDate = joinDate; Contribution = contribution; Rank = rank; }
public Tribesman(ITribe tribe, IPlayer player, ITribeRank rank) { Tribe = tribe; Player = player; JoinDate = DateTime.UtcNow; Rank = rank; Contribution = new Resource(); }
private string RankUpdate(Session session, string[] parms) { bool help = false; string tribeName = string.Empty; string rank = string.Empty; string name = string.Empty; string permission = string.Empty; try { var p = new OptionSet { { "?|help|h", v => help = true }, { "tribe=", v => tribeName = v.TrimMatchingQuotes() }, { "rank=", v => rank = v.TrimMatchingQuotes() }, { "name=", v => name = v.TrimMatchingQuotes() }, { "permission=", v => permission = v.TrimMatchingQuotes() }, }; p.Parse(parms); } catch (Exception) { help = true; } if (help || string.IsNullOrEmpty(tribeName) || string.IsNullOrEmpty(rank)) { var str = Enum.GetNames(typeof(TribePermission)).Aggregate((s, s1) => s + "," + s1); return("TribeRankUpdate --rank=rank_id --tribe=tribe_name [--name=rank_name] [--Permission=Permission(" + str + ")]"); } uint tribeId; if (!tribeManager.FindTribeId(tribeName, out tribeId)) { return("Tribe not found"); } ITribe tribe; return(locker.Lock(tribeId, out tribe).Do(() => { ITribeRank tribeRank = tribe.Ranks.First(x => x.Id == byte.Parse(rank)); if (tribeRank == null) { return "Rank not found"; } tribe.UpdateRank(tribeRank.Id, name == string.Empty ? tribeRank.Name : name, permission == string.Empty ? tribeRank.Permission : (TribePermission)Enum.Parse(typeof(TribePermission), permission, true)); return "OK"; })); }