Example #1
0
        public CombatSession CreateCombatSession(Fighter Fighte1, Fighter Fighter2)
        {
            CombatSession combatSession = new CombatSession(Fighte1, Fighter2);

            CombatSessions.Add(combatSession);
            return(combatSession);
        }
Example #2
0
 public bool setSemaphore(string fighterId)
 {
     _semaphoreMutex.WaitOne();
     try
     {
         CombatSession thisCombatSession = GetCombatSessionByFighterId(fighterId);
         if (thisCombatSession.AnimationSemaphore.Count == 0)
         {
             thisCombatSession.AnimationSemaphore.Add(fighterId, true);
             return(false);
         }
         else if (thisCombatSession.AnimationSemaphore.Count == 1)
         {
             if (thisCombatSession.AnimationSemaphore.ContainsKey(fighterId))
             {
                 return(false);
                 // throw new Exception("AnimationSemaphore exception");
             }
             else
             {
                 thisCombatSession.AnimationSemaphore = new Dictionary <string, bool>();
                 return(true);
             }
         }
         else
         {
             throw new Exception("AnimationSemaphore exception");
         }
     }
     finally
     {
         _semaphoreMutex.ReleaseMutex();
     }
 }
Example #3
0
        public async void CombatMove([FromBody] CombatMove Move)
        {
            CombatSession thisCombatSession = _combatManager.GetCombatSessionByFighterId(Move.FighterId);
            CombatResult  result            = thisCombatSession.AddMove(Move);

            //CombatResult result = _combatManager.AddMove(Move);

            if (result != null)
            {
                List <string> playerIds = new List <string>();
                playerIds.Add(thisCombatSession.Fighters.ToArray()[0].Value.ownerId);
                playerIds.Add(thisCombatSession.Fighters.ToArray()[1].Value.ownerId);
                //await _chatHubContext.SendCombatResult(playerIds, System.Text.Json.JsonSerializer.Serialize(result));
                _chatHubContext.SendCombatResult(playerIds, System.Text.Json.JsonSerializer.Serialize(result));

                //IDAL dal = new SqlDAL();

                if (result.Victory != null)
                {
                    _combatManager.DeleteSession(playerIds[0]);

                    using (IDbConnection dbConnection =
                               DbProviderFactories.GetFactory("system.data.sqlclient").CreateConnection())
                    {
                        //dbConnection.ConnectionString = "Server=tcp:cipherrex.database.windows.net,1433;Initial Catalog=cipherRexUmbraco;Persist Security Info=False;User ID=cipherrex;Password=R00ksp@wnR00ksp@wn;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;";
                        //dbConnection.Open();
                        //Models.DAL.SqlDAL sqlDAL = new Models.DAL.SqlDAL(dbConnection);

                        //IPlayerRepo playerRepo = new PlayerRepo(sqlDAL);
                        //PlayerUoW playerUoW = new PlayerUoW(sqlDAL, playerRepo);

                        //playerUoW.EndGame(
                        //    result.Victory.VictorFighterId,
                        //    thisCombatSession.Fighters.Where(x => x.Key != result.Victory.VictorFighterId).FirstOrDefault().Key
                        //    );
                    }
                }
            }
        }
 public CombatInstanceResolverBase(CombatSession Session)
 {
     _combatSession = Session;
 }
Example #5
0
 public SwingSwingResolver(CombatSession Session) : base(Session)
 {
 }
Example #6
0
 public CombatHistoryResolverBase(CombatSession Session)
 {
     _combatSession = Session;
 }
Example #7
0
 public CombatResolverFactory(CombatSession combatSession)
 {
     _combatSession = combatSession;
 }
Example #8
0
 public SwingBlockResolver(CombatSession Session) : base(Session)
 {
 }
Example #9
0
 public RestRestResolver(CombatSession Session) : base(Session)
 {
 }
Example #10
0
 public SuccessfulHealHistoryResolver(CombatSession Session) : base(Session)
 {
 }
Example #11
0
 private string ToHtml( CombatSession session )
 {
     string s = string.Empty;
     if( session.TotalDamage > 0 )
         s = string.Format( "<td>{3:HH:mm}</td><td class='lt'>{0} hit <strong>{1}</strong> for <strong>{2:N0}</strong></td><td>{8:0}:{9:00}</td><td>{16:N0}</td><td>{18:N0}</td><td>{17}</td><td>{10:N0}</td><td>{14:N0}</td><td>{5:N0}-{6:N0}</td><td>{15:N2}</td><td>{13:N2}</td><td>{11:N2}</td><td>{12:N2}</td><td>{7:N2}</td><td><strong>{4:N2}</strong></td>",
             session.Source.Name, // 0
             session.Target.Name, // 1
             session.TotalDamage, // 2
             session.StartingTime, // 3
             session.TotalDps, // 4
             session.MinDamage, // 5
             session.MaxDamage, // 6
             session.AverageDamage, // 7
             session.Elapsed.Minutes, // 8
             session.Elapsed.Seconds, // 9
             session.NumHits, // 10
             session.AverageNonCriticalDamage, // 11
             session.AverageCriticalDamage, // 12
             session.AverageDotDamage, // 13
             session.NumMisses, // 14
             session.AverageAutoAttackDamage, // 15
             session.IncomingDamage, // 16
             session.NumDeaths > 0 ? session.NumDeaths.ToString() : "&nbsp;", // 17
             session.IncomingHealing // 18
             );
     else if( session.TotalHealing > 0 )
         s = string.Format( "<td>{3:HH:mm}</td><td class='lt' colspan='14'><span class='heal'>{0} healed <strong>{1}</strong> for {2:N0}</span></td>",
             session.Source.Name,
             session.Target.Name,
             session.TotalHealing,
             session.StartingTime );
     return s;
 }
Example #12
0
        private void AddRow( StringBuilder html, CombatSession session )
        {
            if( session.TotalHealing > 0 )
            {
                this.AddHealingRow( html, session );
                return;
            }

            DamageAnalyzer incoming = new DamageAnalyzer( session.IncomingLog );
            DamageAnalyzer outgoing = new DamageAnalyzer( session.OutgoingLog );

            this.AddCell( html, "{0:HH:mm}", session.StartingTime );
            this.AddCell( html, "<span class='dmg'>{0} vs. <strong>{1}</strong></span>", session.Source.Name, session.Target.Name );
            this.AddCell( html, "{0}:{1:00}", session.Elapsed.Minutes, session.Elapsed.Seconds );
            this.AddNumberCell( html, outgoing.totalDamage );
            this.AddCell( html, "{0:N1}", outgoing.TotalDps );
            this.AddCell( html, "{0:N1}", outgoing.AverageDamagePerHit );
            this.AddNumberCell( html, outgoing.maximumNonCritical );
            this.AddNumberCell( html, outgoing.maximumCritical );
            this.AddNumberCell( html, outgoing.numHits );
            this.AddNumberCell( html, outgoing.numMisses );
            this.AddNumberCell( html, incoming.numDeaths );
        }
Example #13
0
        private void AddHealingRow( StringBuilder html, CombatSession session )
        {
            DamageAnalyzer incoming = new DamageAnalyzer( session.IncomingLog );
            DamageAnalyzer outgoing = new DamageAnalyzer( session.OutgoingLog );

            this.AddCell( html, "{0:HH:mm}", session.StartingTime );
            this.AddCell( html, "<span class='heal'>{0} healed <strong>{1}</strong></span>", session.Source.Name, session.Target.Name );
            this.AddCell( html, "{0}:{1:00}", session.Elapsed.Minutes, session.Elapsed.Seconds );
            this.AddNumberCell( html, outgoing.totalHealing );
            this.AddCell( html, "{0:N1}", outgoing.TotalHps );
            this.AddCell( html, "{0:N1}", outgoing.AverageHealPerHit);
            this.AddNumberCell( html, outgoing.maximumNonCriticalHealing );
            this.AddNumberCell( html, outgoing.maximumCriticalHealing );
            this.AddNumberCell( html, outgoing.numHeals );
            this.AddCell( html, "&nbsp;", 0 );
            this.AddNumberCell( html, incoming.numDeaths );
        }
Example #14
0
 public BlockBlockResolver(CombatSession Session) : base(Session)
 {
 }
Example #15
0
 public FalseBlockHistoryResolver(CombatSession Session) : base(Session)
 {
 }
 public SuccessfulStrikeHistoryResolver(CombatSession Session) : base(Session)
 {
 }