private StatsRecord GetStatsRecord(StatsRecord request) { var id = request?.Id; StatsRecord ret = null; var query = DocQuery.ActiveQuery ?? Execute; DocPermissionFactory.SetSelect <StatsRecord>(currentUser, "StatsRecord", request.Select); DocEntityStatsRecord entity = null; if (id.HasValue) { entity = DocEntityStatsRecord.Get(id.Value); } if (null == entity) { throw new HttpError(HttpStatusCode.NotFound, $"No StatsRecord found for Id {id.Value}"); } if (!DocPermissionFactory.HasPermission(entity, currentUser, DocConstantPermission.VIEW)) { throw new HttpError(HttpStatusCode.Forbidden, "You do not have VIEW permission for this route."); } ret = entity?.ToDto(); return(ret); }
public static void AddVitality(Fighter fighter, SpellLevelRecord level, ExtendedSpellEffect effect, List <Fighter> affected, short castcellid) { foreach (var target in affected) { var definition = new UInt16ReflectedStat(StatsRecord.GetFieldInfo("LifePoints"), target.FighterStats.Stats); target.AddBuff(new StatBuff((uint)target.BuffIdProvider.Pop(), definition, (uint)ActionsEnum.ACTION_CHARACTER_BOOST_VITALITY, effect.BaseEffect.DiceNum, effect.BaseEffect.Duration, fighter.ContextualId, (short)level.SpellId, effect.BaseEffect.DiceNum, effect.BaseEffect.Delay)); } }
public static void AddDamageBonus(Fighter fighter, SpellLevelRecord level, ExtendedSpellEffect effect, List <Fighter> affecteds, short castcellid) { foreach (var target in affecteds) { var definition = new UInt16ReflectedStat(StatsRecord.GetFieldInfo("AllDamagesBonus"), target.FighterStats.Stats); target.AddBuff(new StatBuff((uint)target.BuffIdProvider.Pop(), definition, (uint)effect.BaseEffect.EffectType, effect.BaseEffect.DiceNum, effect.BaseEffect.Duration, fighter.ContextualId, (short)level.SpellId, effect.BaseEffect.DiceNum, effect.BaseEffect.Delay)); } }
public static void EarthResistPercent(Fighter fighter, SpellLevelRecord level, ExtendedSpellEffect effect, List <Fighter> affecteds, short castcellid) { foreach (var target in affecteds) { var statdefinition = new UInt16ReflectedStat(StatsRecord.GetFieldInfo("EarthResistPercent"), fighter.FighterStats.Stats); StatBuff buff = new StatBuff((uint)target.BuffIdProvider.Pop(), statdefinition, (uint)effect.BaseEffect.EffectType, effect.BaseEffect.DiceNum, effect.BaseEffect.Duration, fighter.ContextualId, (short)level.SpellId, effect.BaseEffect.DiceNum, effect.BaseEffect.Delay); target.AddBuff(buff); } }
public FighterStats(StatsRecord record, bool summoned = false, int summonerid = 0) { this.RealStats = record.Clone(); this.Stats = RealStats.Clone(); this.ShieldPoints = 0; this.ErosionPercentage = 0; this.ErodedLife = 0; this.Summoned = summoned; this.SummonerId = summonerid; }
public FighterStats GetFighterStats(Character master) { List <object> constructorDatas = new List <object>(); foreach (var field in typeof(StatsRecord).GetFields().ToList().FindAll(x => !x.IsStatic).OrderBy(x => x.MetadataToken)) { constructorDatas.Add(GetStatData(master, field.Name)); } StatsRecord stats = (StatsRecord)Activator.CreateInstance(typeof(StatsRecord), constructorDatas.ToArray()); stats.Initiative = (short)(master.Initiative - 1); stats.Strength = master.StatsRecord.Strength; stats.Agility = master.StatsRecord.Agility; stats.Intelligence = master.StatsRecord.Intelligence; stats.Chance = master.StatsRecord.Chance; return(new FighterStats(stats)); }
static void ProcessSelection(WorldClient client) { client.Send(new CharacterSelectedSuccessMessage(new CharacterBaseInformations((uint)client.Character.Id, (byte)client.Character.Record.Level, client.Character.Record.Name, client.Character.Look.ToEntityLook(), (sbyte)client.Character.Record.Breed, client.Character.Record.Sex), false)); StatsRecord.InitializeCharacter(client.Character); client.Character.Inventory.Refresh(); client.Character.RefreshShortcuts(); client.Character.RefreshEmotes(); client.Character.InitializeCosmetics(); client.Character.RefreshJobs(); client.Character.RefreshSpells(); client.Character.RefreshArenasInfos(); client.Character.RefreshPvPInfos(); client.Character.OnConnectedGuildInformations(); client.Character.OnConnectedAllianceInformations(); client.Character.OnConnectedNotifications(); client.Send(new CharacterCapabilitiesMessage(4095)); client.Send(new CharacterLoadingCompleteMessage()); }
public PartyInvitationMemberInformations GetPartyInvitationMemberInformations() { CharacterRecord record = this.Character.Record; StatsRecord stats = this.Character.StatsRecord; BasicStats current = this.Character.CurrentStats; int id = record.Id; int level = (int)record.Level; string name = record.Name; EntityLook entityLook = this.Character.Look.ToEntityLook(); int breed = (int)(sbyte)record.Breed; bool sex = record.Sex; int mapid = (int)(short)record.MapId; PartyCompanionMemberInformations[] memberInformationsArray = new PartyCompanionMemberInformations[0]; return(new PartyInvitationMemberInformations((uint)id, (byte)level, name, entityLook, (sbyte)breed, sex, (short)this.Character.Map.Position.x, (short)this.Character.Map.Position.y, this.Character.Map.Id, (ushort)this.Character.SubAreaId, memberInformationsArray)); }
public PartyMemberInformations GetPartyMemberInformations() { CharacterRecord record = this.Character.Record; StatsRecord stats = this.Character.StatsRecord; BasicStats current = this.Character.CurrentStats; int id = record.Id; int level = (int)record.Level; string name = record.Name; EntityLook entityLook = this.Character.Look.ToEntityLook(); int breed = (int)(sbyte)record.Breed; bool sex = record.Sex; int hp = (int)this.Character.CurrentStats.LifePoints; int maxhp = stats.LifePoints; int regen = (int)1; int align = (int)(sbyte)record.AlignmentSide; int mapid = (int)(short)record.MapId; PlayerStatus status = this.Character.PlayerStatus; PartyCompanionMemberInformations[] memberInformationsArray = new PartyCompanionMemberInformations[0]; return(new PartyMemberInformations((uint)id, (byte)level, name, entityLook, (sbyte)breed, sex, (uint)hp, (uint)maxhp, (ushort)stats.Prospecting, (byte)regen, (ushort)this.Character.Initiative, (sbyte)align, (short)this.Character.Map.Position.x, (short)this.Character.Map.Position.y, this.Character.Map.Id, (ushort)this.Character.SubAreaId, status, (IEnumerable <PartyCompanionMemberInformations>)memberInformationsArray)); }
public static void HandleCharacterDeletion(CharacterDeletionRequestMessage message, WorldClient client) // finish this { CharacterRecord deletedCharacter = CharacterRecord.GetCharacterRecordById(message.characterId); if (deletedCharacter == null) { return; } StatsRecord.GetStatsRecord(message.characterId).RemoveElement(); CharacterRecord.Characters.Remove(deletedCharacter); client.Characters.Remove(deletedCharacter); deletedCharacter.RemoveElement(); CharacterItemRecord.RemoveAll(message.characterId); GeneralShortcutRecord.RemoveAll(message.characterId); CharacterSpellRecord.RemoveAll(message.characterId); CharacterJobRecord.RemoveAll(message.characterId); BidShopGainRecord.RemoveAll(message.characterId); CharacterGuildRecord.RemoveAll(message.characterId); // Si il est meneur de guilde? BidShopItemRecord.RemoveAll(message.characterId); Logger.Log("Character " + deletedCharacter.Name + " deleted"); client.Send(new CharactersListMessage(client.Characters.ConvertAll <CharacterBaseInformations>(x => x.GetBaseInformation()), false)); }
public static void HandleCharacterCreationRequest(CharacterCreationRequestMessage message, WorldClient client) { if (client.Characters.Count() == client.Account.MaxCharactersCount) { client.Send(new CharacterCreationResultMessage((sbyte)CharacterCreationResultEnum.ERR_TOO_MANY_CHARACTERS)); return; } if (CharacterRecord.CheckCharacterNameExist(message.name)) { client.Send(new CharacterCreationResultMessage((sbyte)CharacterCreationResultEnum.ERR_NAME_ALREADY_EXISTS)); return; } if (client.Account.Role <= ServerRoleEnum.MODERATOR) { foreach (var value in message.name) { if (UnauthorizedNameContent.Contains(value)) { client.Send(new CharacterCreationResultMessage((sbyte)CharacterCreationResultEnum.ERR_INVALID_NAME)); return; } } } string look = BreedRecord.GetBreedEntityLook((int)message.breed, message.sex, (int)message.cosmeticId, message.colors).ConvertToString(); CharacterRecord newCharacter = CharacterRecord.Default(message.name, client.Account.Id, look, message.breed, message.sex); client.Character = new Character(newCharacter, client); client.Character.IsNew = true; StatsRecord.Create(client.Character); client.Character.SetLevel(ConfigurationManager.Instance.StartLevel); client.Character.Record.AddElement(); client.Character.UpdateBreedSpells(); client.Character.LearnAllJobs(); Logger.Log("Character " + newCharacter.Name + " created!"); ProcessSelection(client); }
public UInt16ReflectedStat GetStatData() { switch (PunishementAction) { case 118: return(new UInt16ReflectedStat(StatsRecord.GetFieldInfo("ContextStrength"), Fighter.FighterStats.Stats)); case 119: return(new UInt16ReflectedStat(StatsRecord.GetFieldInfo("ContextAgility"), Fighter.FighterStats.Stats)); case 123: return(new UInt16ReflectedStat(StatsRecord.GetFieldInfo("ContextChance"), Fighter.FighterStats.Stats)); case 124: return(new UInt16ReflectedStat(StatsRecord.GetFieldInfo("ContextWisdom"), Fighter.FighterStats.Stats)); case 126: return(new UInt16ReflectedStat(StatsRecord.GetFieldInfo("ContextIntelligence"), Fighter.FighterStats.Stats)); case 407: return(new UInt16ReflectedStat(StatsRecord.GetFieldInfo("LifePoints"), Fighter.FighterStats.Stats)); } return(null); }
private void DoMechanoidAttack() { IntVec3 startPos; string str = txtArtefactActivatedMechanoids.Translate(); // Find a valid spawn position startPos = CellFinderLoose.RandomCellWith((IntVec3 c) => { if (Map.fogGrid.IsFogged(c)) { return(false); } if (!Map.reachability.CanReachColony(c)) { return(false); } if (Map.roofGrid.Roofed(c)) { return(false); } return(true); }, Map); int countPawns; Faction faction = Faction.OfMechanoids; List <Pawn> pawns = new List <Pawn>(); PawnKindDef pawnKindDef; // Spawn mechanoids // Random: What type is spawned? float rvalue = UnityEngine.Random.@value; if (rvalue < 0.5f) { // Spawn Centipedes rvalue = UnityEngine.Random.@value; // Random: How many? if (rvalue < 0.30f) { countPawns = 1; } else if (rvalue < 0.65f) { countPawns = 2; } else { countPawns = 5; // max or when points to spend are done } pawnKindDef = PawnKindDef.Named(pawnKindDefNameCentipede); } else { // Spawn Scythers rvalue = UnityEngine.Random.@value; // Random: How many? if (rvalue < 0.30f) { countPawns = 1; } else if (rvalue < 0.55f) { countPawns = 2; } else { countPawns = 7; // max or when points to spend are done } rvalue = UnityEngine.Random.@value; // Random: which kind? if (rvalue < 0.40f) { pawnKindDef = PawnKindDef.Named(pawnKindDefNameScyther); } else { pawnKindDef = PawnKindDef.Named(pawnKindDefNameLancer); } } // Create mechanoids for (int i = 0; i < countPawns; i++) { IntVec3 spawnPos; if (i == 0) { spawnPos = startPos; } else { spawnPos = CellFinder.RandomClosewalkCellNear(startPos, Map, 15); } Pawn pawn = PawnGenerator.GeneratePawn(pawnKindDef, faction); if (GenPlace.TryPlaceThing(pawn, spawnPos, Map, ThingPlaceMode.Near)) { pawns.Add(pawn); pointsToSpend -= pawn.kindDef.combatPower; //Log.Error("Points: " + pointsToSpend.ToString() + " // Costs: " + pawn.kindDef.pointsCost.ToString()); // TEST!!! if (pointsToSpend <= 0.5f) { break; } } } // Create Lord string empty = string.Empty; string empty2 = string.Empty; PawnRelationUtility.Notify_PawnsSeenByPlayer_Letter(pawns, ref empty, ref empty2, "LetterFamilyMembersRaidFriendly".Translate(), false); if (!empty2.NullOrEmpty()) { Find.LetterStack.ReceiveLetter(empty, empty2, LetterDefOf.PositiveEvent, new GlobalTargetInfo(pawns[0].Position, pawns[0].Map), null); } LordJob lordJob = new LordJob_AssaultColony(faction, true, false, false); Lord lord = LordMaker.MakeNewLord(faction, lordJob, Map, pawns); //AvoidGridMaker.RegenerateAvoidGridsFor(faction, Map); Map.avoidGrid.Regenerate(); LessonAutoActivator.TeachOpportunity(ConceptDefOf.EquippingWeapons, OpportunityType.Critical); string label = labelLetterArtefact.Translate(); // add game event Find.LetterStack.ReceiveLetter(label, str, LetterDefOf.ThreatSmall, pawns[0], null); // add raid to story watcher StatsRecord storyWatcher = Find.StoryWatcher.statsRecord; storyWatcher.numRaidsEnemy = storyWatcher.numRaidsEnemy + 1; }
private void DoRaiderAttack() { IntVec3 startPos; string str = txtArtefactActivatedRaiders.Translate(); // Find a valid spawn position if (!RCellFinder.TryFindRandomPawnEntryCell(out startPos, Map, CellFinder.EdgeRoadChance_Hostile, false, null)) { return; } int countPawns; IEnumerable <Faction> factions = Find.FactionManager.AllFactions.Where <Faction>(f => f.HostileTo(Faction.OfPlayer) && f != Faction.OfMechanoids && f != Faction.OfInsects); Faction faction; if (!factions.TryRandomElement(out faction)) { return; } List <Pawn> pawns = new List <Pawn>(); // Spawn raiders float rvalue = UnityEngine.Random.@value; countPawns = (int)UnityEngine.Random.Range(0.0f, 15.0f); // Random: max. count of pawns if (countPawns <= 0) { countPawns = 1; } // Create raider for (int i = 0; i < countPawns; i++) { IntVec3 spawnPos; if (i == 0) { spawnPos = startPos; } else { spawnPos = CellFinder.RandomClosewalkCellNear(startPos, Map, 8); } //pawnKindDefs = DefDatabase<PawnKindDef>.AllDefs.Where<PawnKindDef>(pk => pk.defaultFactionType.defName == "Spacer" || pk.defaultFactionType.defName == "Pirate").ToList(); Pawn pawn = PawnGenerator.GeneratePawn(pawnKindDefs.RandomElement(), faction); if (GenPlace.TryPlaceThing(pawn, spawnPos, Map, ThingPlaceMode.Near)) { pawns.Add(pawn); pointsToSpend -= pawn.kindDef.combatPower; //Log.Error("Points: " + pointsToSpend.ToString() + " // Costs: " + pawn.kindDef.pointsCost.ToString()); // TEST!!! if (pointsToSpend <= 0.0f) { break; } } } // Create Lord string empty = string.Empty; string empty2 = string.Empty; PawnRelationUtility.Notify_PawnsSeenByPlayer_Letter(pawns, ref empty, ref empty2, "LetterFamilyMembersRaidFriendly".Translate(), false); if (!empty2.NullOrEmpty()) { Find.LetterStack.ReceiveLetter(empty, empty2, LetterDefOf.PositiveEvent, new GlobalTargetInfo(pawns[0].Position, pawns[0].Map), null); } LordJob lordJob = new LordJob_AssaultColony(faction, false, false, false); Lord lord = LordMaker.MakeNewLord(faction, lordJob, Map, pawns); //AvoidGridMaker.RegenerateAvoidGridsFor(faction, Map); Map.avoidGrid.Regenerate(); LessonAutoActivator.TeachOpportunity(ConceptDefOf.EquippingWeapons, OpportunityType.Critical); string label = labelLetterArtefact.Translate(); // add game event Find.LetterStack.ReceiveLetter(label, str, LetterDefOf.ThreatSmall, pawns[0], null); // add raid to story watcher StatsRecord storyWatcher = Find.StoryWatcher.statsRecord; storyWatcher.numRaidsEnemy = storyWatcher.numRaidsEnemy + 1; }
public UInt16ReflectedStat(FieldInfo field, StatsRecord host) { this.Field = field; this.Host = host; }
private void btnConnect_Click(object sender, RoutedEventArgs e) { if (isInternetup) { if (Properties.Settings.Default.CodingIP != null && Properties.Settings.Default.CodingIP != "" && Properties.Settings.Default.CurrentID != "" && Properties.Settings.Default.CurrentID != null) { if (Properties.Settings.Default.isConnected) { //DISCONNECTED Log("Console leave Coding service"); _CallOut_CodingService.ConsoleLeave(Properties.Settings.Default.CurrentID); //Change title of application this.Title = "Call Out Console"; //Toggle button display Properties.Settings.Default.isConnected = false; Properties.Settings.Default.Save(); if (waveOut != null) { waveOut.Stop(); } //Empty Display EmptyDisplay(); IncidentMsgQueue.Clear(); //Update hidden label lblStatus = ""; isfirstdisplay = true; countdisplay = 1; counttotal = 0; } else { //CONNECTED //contact the service. Log("Console join Coding service"); _CallOut_CodingService.ConsoleJoin(Properties.Settings.Default.CurrentID); bool isNewStatsRecord = true; foreach (StatsRecord record in StatsRecordList) { if (record.ConsoleName.Equals(Properties.Settings.Default.CurrentID)) { //Continue counting from the leaveover IncidentCount = record.IncidentCount; AckCount = record.AckCount; RejectedCount = record.RejectedCount; FailedCount = record.FailedCount; isNewStatsRecord = false; break; } } if (isNewStatsRecord) { StatsRecord newstatsrecord = new StatsRecord(Properties.Settings.Default.CurrentID, IncidentCount, AckCount, RejectedCount, FailedCount); StatsRecordList.Add(newstatsrecord); } this.txtConsoleName.Text = Properties.Settings.Default.CurrentID; this.txtIncidentAmt.Text = IncidentCount.ToString(); this.txtAckAmt.Text = AckCount.ToString(); this.txtRejectAmt.Text = RejectedCount.ToString(); this.txtFailedAmt.Text = FailedCount.ToString(); //Change title of application this.Title = "Call Out Console [" + Properties.Settings.Default.CurrentID + "]"; //Toggle button display Properties.Settings.Default.isConnected = true; Properties.Settings.Default.Save(); } } else { ShowMessageBox("Set the IP and Station ID in \"Settings\" to connect to the service"); this.btnConnect.IsChecked = Properties.Settings.Default.isConnected; } } else { this.btnConnect.IsChecked = Properties.Settings.Default.isConnected; ShowMessageBox("Please check the internet connection to continue"); } }
public CharacterCharacteristicsInformations GetCharacterCharacteristics(Character character) { return(StatsRecord.GetCharacterCharacteristics(Stats, character)); }
/// <summary> /// CharacterCharacteristicsInformations /// </summary> public void RefreshStats() { Client.Send(new CharacterStatsListMessage(StatsRecord.GetCharacterCharacteristics(StatsRecord, this))); this.RefreshGroupInformations(); }
static void Main() { Player player1 = new RightyPlayer("Mr first card - right player"); Player player2 = new LeftyPlayer("Mr last card - left player"); Player player3 = new LastCardPlayer("Mr last card - random player"); Player player4 = new RandomPlayer("Mr. Random"); List <Player> players = new List <Player> { player1, player2, player3, player4 }; Deck deck = new Deck(); GameState gameState = new GameState(players, deck); Console.WriteLine(" GoFish simulator\n------------------------------------------"); // find out if we shall show just one game, or loop through many : bool firstOptionChosen; int numberOfGamesToPlay = 1000; Console.WriteLine("would you like to : "); Console.WriteLine("(A) see 1-GoFish game play out?"); Console.WriteLine($"(B) see just the stats from {numberOfGamesToPlay} games playing out?"); Console.Write(" => "); { string input = Console.ReadLine().Trim(); while (input != "A" && input != "B") { Console.WriteLine($"Type \"A\" to watch 1 game, or \"B\" to see results from {numberOfGamesToPlay} games,"); Console.Write(" => "); input = Console.ReadLine().Trim(); } firstOptionChosen = input == "A"; } if (firstOptionChosen) // show 1-game { gameState.BeginGame(); Console.WriteLine(gameState.EmptyDisplayBuffer()); Console.WriteLine("press any key to continue ..."); Console.ReadKey(); while (!gameState.GameOver()) { gameState.TakeTurn(); Console.WriteLine(gameState.EmptyDisplayBuffer()); Console.WriteLine("press any key to continue ..."); Console.ReadKey(); } Console.WriteLine(gameState.WinnerString()); do { Console.Write("type \"done\" to exit : "); }while (Console.ReadLine().Trim() != "done"); } else // run multiple games and then show stats { StatsRecord statsRecord = new StatsRecord(); for (int i = 0; i < numberOfGamesToPlay; i++) { gameState.BeginGame(); int turnCount = 0; while (!gameState.GameOver()) { gameState.TakeTurn(); turnCount++; } Console.WriteLine($"game {i+1} complete"); statsRecord.EnterData(i + 1, turnCount, players); gameState.ResetDeck(); } Console.WriteLine(statsRecord); do { Console.Write("type \"done\" to end program : "); } while (Console.ReadLine().Trim() != "done"); } }
static UInt16ReflectedStat GetReflectedStat(StatsRecord stats, StatsBoostTypeEnum type) { var fieldInfo = StatsRecord.GetFieldInfo("Base" + type.ToString()); return(new UInt16ReflectedStat(fieldInfo, stats)); }
public object Get(StatsRecord request) => GetEntityWithCache <StatsRecord>(DocConstantModelName.STATSRECORD, request, GetStatsRecord);