Ejemplo n.º 1
0
        public Player SavePlayer(Player player)
        {
            var updated = entity.Players.Attach(player);

            entity.Entry(player).State = System.Data.EntityState.Modified;
            return(updated);
        }
Ejemplo n.º 2
0
        public PlayerActionResult DoAction(PlayerActionType type, int uid, string pparam = null, int amount = 0, string svalue = null)
        {
            Player             player;
            PlayerActionResult result;
            PlayerAction       action = (PlayerAction)Activator.CreateInstance(null, string.Concat("Conquest.Players.Actions.", type.ToString())).Unwrap();

            action.Logic        = (ActionLogic)Activator.CreateInstance(null, string.Concat("Conquest.Players.Actions.", type.ToString(), "Logic")).Unwrap();
            action.Logic.Action = action;
            action.amount       = amount;
            // Verify executor exists
            if (!PlayerExists(uid))
            {
                return(new PlayerActionResult(false, ResultType.NotFound));
            }
            else
            {
                player = GetPlayer(uid);
            }

            if (pparam != null & !PlayerExists(pparam))
            {
                if (!PlayerExists(pparam))
                {
                    return(new PlayerActionResult(false, ResultType.NotFound));
                }
                action.playerparam = GetPlayer(pparam);
            }

            result = player.DoAction(action);
            entities.Entry(player).State = System.Data.EntityState.Modified;
            entities.SaveChanges();


            return(result);
        }