コード例 #1
0
ファイル: GameManager.cs プロジェクト: mathborba/Mu.NET-CMS
 public GameMessageId UnstuckChar(string user, string character)
 {
     if (!IsCharacterOwned(user, character)) return GameMessageId.Error;
     if (IsConnected(user)) return GameMessageId.AccountConnected;
     using (var c = new GameDbContext())
     {
         Character ch = c.Characters.Find(character);
         ch.MapNumber = 0;
         ch.MapPosX = 135;
         ch.MapPosY = 127;
         c.SaveChanges();
     }
     return GameMessageId.UnstuckSucces;
 }
コード例 #2
0
ファイル: GameManager.cs プロジェクト: mathborba/Mu.NET-CMS
        public GameMessageId ResetCharacter(string user, string character)
        {
            if (!IsCharacterOwned(user,character)) return GameMessageId.Error;
            if (IsConnected(user)) return GameMessageId.AccountConnected;
            int resetLevel = Int32.Parse(ConfigurationManager.AppSettings["ResetLevel"]);
            int resetCap = Int32.Parse(ConfigurationManager.AppSettings["ResetMax"]);

            using (var c = new GameDbContext())
            {
                Character ch = c.Characters.Find(character);
                //maybe not needed
                //ch = (Character)c.Entry(ch).GetDatabaseValues().ToObject();
                if (ch.cLevel < resetLevel)
                    return GameMessageId.ResetFailLevel;
                else if (ch.Resets >= resetCap) return GameMessageId.ResetFailCap;
                else if (ch.Money < GetResetCost(ch.Resets)) return GameMessageId.ResetFailZen;
                else
                {
                    //db.Users.Attach(updatedUser);
                    //var entry = db.Entry(updatedUser);
                    //entry.Property(e => e.Email).IsModified = true;
                    //// other changed properties
                    //db.SaveChanges();
                    ch.cLevel = 1;
                    ch.Experience = 0;
                    ch.Money -= GetResetCost(ch.Resets);
                    ch.MapNumber = 0;
                    ch.MapPosX = 182;
                    ch.MapPosY = 128;
                    ch.Resets += 1;
                    c.SaveChanges();
                    //c.Entry(ch).GetDatabaseValues();
                    return GameMessageId.ResetSuccess;
                }

            }
        }