Esempio n. 1
0
        private async void YesButton_Click(object sender, RoutedEventArgs e)
        {
            DbStatus status = await doctorService.Delete(Mapping.Mapper.Map <Doctor>(doctorViewModel));

            OperationStatus = StatusHandler.Handle(OperationType.Delete, status);
            Close();
        }
        private async void SaveButton_Click(object sender, RoutedEventArgs e)
        {
            if (FormIsValid())
            {
                MedicalRecord medicalRecord = new MedicalRecord()
                {
                    IdMedicalRecord   = medicalRecordViewModel.IdMedicalRecord,
                    Name              = FirstNameBox.Text,
                    LastName          = LastNameBox.Text,
                    BirthDate         = BirthDatePicker.SelectedDate.Value,
                    BirthPlace        = BirthPlaceBox.Text,
                    FathersFullName   = FathersNameBox.Text,
                    MothersFullName   = MothersNameBox.Text,
                    FathersProfession = FathersProfessionBox.Text,
                    MothersProfession = MothersProfessionBox.Text,
                    Gender            = (sbyte)(MaleCheckBox.IsChecked.Value ? 0 : 1),
                    MarriageStatus    = (sbyte)(MarriedCheckBox.IsChecked.Value ? 0 : 1),
                    Jmb             = UNBBox.Text,
                    InsuranceNumber = InsuranceNumberBox.Text,
                    IdResidence     = ((PlaceViewModel)ResidancePlaceComboBox.SelectedItem).IdPlace
                };
                DbStatus status = await medicalRecordService.Update(medicalRecord);

                OperationStatus = StatusHandler.Handle(OperationType.Edit, status);
                Close();
            }
            else
            {
                FieldValidation.WriteMessage(ErrorLabel, language.SelectValues);
            }
        }
Esempio n. 3
0
        public override void Execute(GameCommandTrigger trigger)
        {
            int id = trigger.Get <int>("id");

            if (SkillMetadataStorage.GetSkill(id) == null)
            {
                trigger.Session.SendNotice($"No skill found with id: {id}");
                return;
            }

            short level = trigger.Get <short>("level") <= 10 && trigger.Get <short>("level") != 0 ? trigger.Get <short>("level") : (short)1;
            // The Status packet needs this in miliseconds, we are converting them here for the user to just input the actual seconds.
            int duration = trigger.Get <int>("duration") <= 3600 && trigger.Get <int>("duration") != 0 ? trigger.Get <int>("duration") * 1000 : 10000;
            int stacks   = trigger.Get <int>("stacks") == 0 ? 1 : trigger.Get <int>("stacks");

            SkillCast skillCast = new SkillCast(id, level);

            if (skillCast.IsBuffToOwner() || skillCast.IsBuffToEntity() || skillCast.IsBuffShield() || skillCast.IsGM() || skillCast.IsGlobal() || skillCast.IsHealFromBuff())
            {
                Status status = new Status(skillCast, trigger.Session.FieldPlayer.ObjectId, trigger.Session.FieldPlayer.ObjectId, stacks);
                StatusHandler.Handle(trigger.Session, status);
                return;
            }

            trigger.Session.SendNotice($"Skill with id: {id} is not a buff to the owner.");
        }
Esempio n. 4
0
        private async void SaveButton_Click(object sender, RoutedEventArgs e)
        {
            if (FormIsValid())
            {
                Place place = new Place()
                {
                    Name                     = NameBox.Text,
                    CountryName              = CountryNameBox.Text,
                    PostalCode               = PostalCodeBox.Text,
                    FoodQuality              = (int)FoodQualityComboBox.SelectedItem,
                    AirQuality               = (int)AirQualityComboBox.SelectedItem,
                    DrinkingWaterQuality     = (int)DrinkingWaterComboBox.SelectedItem,
                    RecreationalWaterQuality = (int)RecreationalWaterComboBox.SelectedItem,
                    TerrainQuality           = (int)TerrainQualityComboBox.SelectedItem,
                    InlandWaterQuality       = (int)InlandWaterQualityComboBox.SelectedItem,
                    MedicalVasteInformation  = (int)MedicalVasteComboBox.SelectedItem,
                    NoiseInformation         = (int)NoiseInformationComboBox.SelectedItem,
                    Radiation                = (int)RadiationComboBox.SelectedItem
                };
                DbStatus status = await placeService.Add(place);

                OperationStatus = StatusHandler.Handle(OperationType.Create, status);
                Close();
            }
            else
            {
                FieldValidation.WriteMessage(ErrorLabel, language.SelectValues);
            }
        }
        private async void SaveButton_Click(object sender, RoutedEventArgs e)
        {
            if (!AreSamePasswords())
            {
                FieldValidation.WriteMessage(ErrorLabel, language.PasswordsDontMatch);
                return;
            }
            if (IsValidForm())
            {
                LocalAccount localAccount = new LocalAccount()
                {
                    IdLocalAccount = localAccountViewModel.IdLocalAccount,
                    FullName       = FullNameBox.Text,
                    Email          = EmailBox.Text,
                    PasswordHash   = PasswordBox.Password,
                };
                ObservableCollection <RoleViewModel> roles = RolesComboBox.SelectedItems as ObservableCollection <RoleViewModel>;
                localAccount.SetRoles(roles.Select(x => Mapping.Mapper.Map <Role>(x)).ToList());
                DbStatus status = await localAccountService.Update(localAccount);

                OperationStatus = StatusHandler.Handle(OperationType.Edit, status);
                Close();
            }
            else
            {
                FieldValidation.WriteMessage(ErrorLabel, language.SelectValues);
            }
        }
        private async void YesButton_Click(object sender, RoutedEventArgs e)
        {
            DbStatus status = await medicalTitleService.Delete(Mapping.Mapper.Map <MedicalTitle>(medicalTitle));

            OperationStatus = StatusHandler.Handle(OperationType.Delete, status);
            Close();
        }
Esempio n. 7
0
        public override void Cast(SkillCast skillCast)
        {
            int spiritCost  = skillCast.GetSpCost();
            int staminaCost = skillCast.GetStaCost();

            if (Value.Stats[StatId.Spirit].Total < spiritCost || Value.Stats[StatId.Stamina].Total < staminaCost)
            {
                return;
            }

            SkillCast = skillCast;

            ConsumeSp(spiritCost);
            ConsumeStamina(staminaCost);
            Value.Session.SendNotice(skillCast.SkillId.ToString());

            // TODO: Move this and all others combat cases like recover sp to its own class.
            // Since the cast is always sent by the skill, we have to check buffs even when not doing damage.
            if (skillCast.IsBuffToOwner() || skillCast.IsBuffToEntity() || skillCast.IsBuffShield() || skillCast.IsDebuffToOwner())
            {
                Status status = new(skillCast, ObjectId, ObjectId, 1);
                StatusHandler.Handle(Value.Session, status);
            }

            Value.Session.FieldManager.BroadcastPacket(SkillUsePacket.SkillUse(skillCast));
            Value.Session.Send(StatPacket.SetStats(this));

            StartCombatStance();
        }
Esempio n. 8
0
        private async void YesButton_Click(object sender, RoutedEventArgs e)
        {
            DbStatus status = await localAccountService.Delete(Mapping.Mapper.Map <LocalAccount>(localAccountViewModel));

            OperationStatus = StatusHandler.Handle(OperationType.Delete, status);
            Close();
        }
Esempio n. 9
0
        private async void SaveButton_Click(object sender, RoutedEventArgs e)
        {
            if (IsValidForm())
            {
                DbStatus status = await roleService.Add(new Role()
                {
                    RoleName = NameBox.Text
                });

                OperationStatus = StatusHandler.Handle(OperationType.Create, status);
                Close();
            }
            else
            {
                FieldValidation.WriteMessage(ErrorLabel, language.SelectValues);
            }
        }
        private async void SaveButton_Click(object sender, RoutedEventArgs e)
        {
            if (IsValidForm())
            {
                DbStatus status = await clinicService.Add(new Clinic()
                {
                    Name    = NameBox.Text,
                    IdPlace = ((PlaceViewModel)PlaceComboBox.SelectedItem).IdPlace
                });

                OperationStatus = StatusHandler.Handle(OperationType.Create, status);
                Close();
            }
            else
            {
                FieldValidation.WriteMessage(ErrorLabel, language.SelectValues);
            }
        }
Esempio n. 11
0
        private async void SaveButton_Click(object sender, RoutedEventArgs e)
        {
            if (IsValidForm())
            {
                DbStatus status = await medicalTitleService.Update(new MedicalTitle()
                {
                    Name           = NameBox.Text,
                    IdMedicalTitle = medicalTitle.IdMedicalTitle
                });

                OperationStatus = StatusHandler.Handle(OperationType.Edit, status);
                Close();
            }
            else
            {
                FieldValidation.WriteMessage(ErrorLabel, language.SelectValues);
            }
        }
Esempio n. 12
0
    public void AddBuff(int[] boxIds, int skillId, byte skillLevel, bool arg4, bool arg5, string feature)
    {
        foreach (int boxId in boxIds)
        {
            MapTriggerBox box = MapEntityMetadataStorage.GetTriggerBox(Field.MapId, boxId);
            if (box is null)
            {
                return;
            }

            foreach (Character player in Field.State.Players.Values.Where(player => FieldManager.IsPlayerInBox(box, player)))
            {
                // TODO: Rework when buff system is implemented
                Status status = new(new(skillId, skillLevel), player.ObjectId, player.ObjectId, 1);
                StatusHandler.Handle(player.Value.Session, status);
            }
        }
    }
        private async void SaveButton_Click(object sender, RoutedEventArgs e)
        {
            if (IsValidForm())
            {
                doctor.Name           = FirstNameBox.Text;
                doctor.LastName       = LastNameBox.Text;
                doctor.IdLocalAccount = ((LocalAccountViewModel)AccountComboBox.SelectedItem).IdLocalAccount;
                doctor.WorkExperience = int.Parse(WorkExperienceBox.Text);
                DbStatus status = await doctorService.Update(Mapping.Mapper.Map <Doctor>(doctor));

                OperationStatus = StatusHandler.Handle(OperationType.Edit, status);
                Close();
            }
            else
            {
                FieldValidation.WriteMessage(ErrorLabel, language.SelectValues);
            }
        }
Esempio n. 14
0
        private static void HandleDamage(GameSession session, PacketReader packet)
        {
            List <(IFieldObject <Mob>, DamageHandler)> mobs = new List <(IFieldObject <Mob>, DamageHandler)>();
            long   skillSN        = packet.ReadLong();
            int    attackCounter  = packet.ReadInt();
            int    playerObjectId = packet.ReadInt();
            CoordF position       = packet.Read <CoordF>();
            CoordF impactPos      = packet.Read <CoordF>();
            CoordF rotation       = packet.Read <CoordF>();
            int    attackPoint    = packet.ReadByte();
            byte   count          = packet.ReadByte();

            packet.ReadInt();

            bool isCrit = DamageHandler.RollCrit(session.Player.Stats[PlayerStatId.CritRate].Current);

            for (int i = 0; i < count; i++)
            {
                int entity = packet.ReadInt();
                packet.ReadByte();

                IFieldObject <Mob> mob = session.FieldManager.State.Mobs.GetValueOrDefault(entity);
                if (mob == null)
                {
                    continue;
                }

                DamageHandler damage = DamageHandler.CalculateDamage(session.FieldPlayer.Value.SkillCast, session.FieldPlayer.Value, mob.Value, isCrit);

                mob.Value.Damage(damage.Damage);
                session.Send(StatPacket.UpdateMobStats(mob));

                if (mob.Value.IsDead)
                {
                    HandleMobKill(session, mob);
                }

                mobs.Add((mob, damage));

                // TODO: Check if the skill is a debuff for an entity
                SkillCast skillCast = session.FieldPlayer.Value.SkillCast;
                if (skillCast.IsDebuffElement() || skillCast.IsDebuffToEntity() || skillCast.IsDebuffElement())
                {
                    Status status = new Status(session.FieldPlayer.Value.SkillCast, mob.ObjectId, session.FieldPlayer.ObjectId, 1);
                    StatusHandler.Handle(session, status);
                }
            }
            // TODO: Verify if its the player or an ally
            if (session.FieldPlayer.Value.SkillCast.IsHeal())
            {
                Status status = new Status(session.FieldPlayer.Value.SkillCast, session.FieldPlayer.ObjectId, session.FieldPlayer.ObjectId, 1);
                StatusHandler.Handle(session, status);

                // TODO: Heal based on stats
                session.FieldManager.BroadcastPacket(SkillDamagePacket.Heal(status, 50));
                session.FieldPlayer.Value.Stats.Increase(PlayerStatId.Hp, 50);
                session.Send(StatPacket.UpdateStats(session.FieldPlayer, PlayerStatId.Hp));
            }
            else
            {
                session.FieldManager.BroadcastPacket(SkillDamagePacket.Damage(skillSN, attackCounter, position, rotation, session.FieldPlayer, mobs));
            }
        }
Esempio n. 15
0
    private static void HandleDamage(GameSession session, PacketReader packet)
    {
        long   skillSn        = packet.ReadLong();
        int    attackCounter  = packet.ReadInt();
        int    playerObjectId = packet.ReadInt();
        CoordF position       = packet.Read <CoordF>();
        CoordF impactPos      = packet.Read <CoordF>();
        CoordF rotation       = packet.Read <CoordF>();
        int    attackPoint    = packet.ReadByte();
        byte   count          = packet.ReadByte();

        packet.ReadInt();

        IFieldActor <Player> fieldPlayer = session.Player.FieldPlayer;

        SkillCast skillCast = fieldPlayer.SkillCast;

        if (skillCast is null || skillCast.SkillSn != skillSn)
        {
            return;
        }

        // TODO: Verify if its the player or an ally
        if (skillCast.IsRecovery())
        {
            Status status = new(skillCast, fieldPlayer.ObjectId, fieldPlayer.ObjectId, 1);
            StatusHandler.Handle(session, status);

            // TODO: Heal based on stats
            fieldPlayer.Heal(session, status, 50);
            return;
        }

        bool isCrit = DamageHandler.RollCrit(session.Player.Stats[StatId.CritRate].Total);
        List <(int targetId, byte damageType, double damage)> damages = new();

        for (int i = 0; i < count; i++)
        {
            int entityId = packet.ReadInt();
            packet.ReadByte();

            if (entityId == playerObjectId)
            {
                damages.Add(new(playerObjectId, 0, 0));
                continue;
            }

            IFieldActor <NpcMetadata> mob = session.FieldManager.State.Mobs.GetValueOrDefault(entityId);
            if (mob == null)
            {
                continue;
            }
            skillCast.Target = mob;

            DamageHandler damage = DamageHandler.CalculateDamage(skillCast, fieldPlayer, mob, isCrit);

            mob.Damage(damage, session);

            damages.Add(new(damage.Target.ObjectId, (byte)(isCrit ? 1 : 0), damage.Damage));

            // TODO: Check if the skill is a debuff for an entity
            if (!skillCast.IsDebuffElement() && !skillCast.IsDebuffToEntity() && !skillCast.IsDebuffElement())
            {
                continue;
            }

            Status status = new(skillCast, mob.ObjectId, fieldPlayer.ObjectId, 1);
            StatusHandler.Handle(session, status);
        }

        session.FieldManager.BroadcastPacket(SkillDamagePacket.Damage(skillCast, attackCounter, position, rotation, damages));
    }
Esempio n. 16
0
    private static void HandleDamage(GameSession session, PacketReader packet)
    {
        long   skillSN        = packet.ReadLong();
        int    attackCounter  = packet.ReadInt();
        int    playerObjectId = packet.ReadInt();
        CoordF position       = packet.Read <CoordF>();
        CoordF impactPos      = packet.Read <CoordF>();
        CoordF rotation       = packet.Read <CoordF>();
        int    attackPoint    = packet.ReadByte();
        byte   count          = packet.ReadByte();

        packet.ReadInt();

        IFieldActor <Player> fieldPlayer = session.Player.FieldPlayer;

        bool isCrit = DamageHandler.RollCrit(session.Player.Stats[StatId.CritRate].Total);

        // TODO: Check if skillSN matches server's current skill for the player
        // TODO: Verify if its the player or an ally
        if (fieldPlayer.SkillCast.IsHeal())
        {
            Status status = new(fieldPlayer.SkillCast, fieldPlayer.ObjectId, fieldPlayer.ObjectId, 1);
            StatusHandler.Handle(session, status);

            // TODO: Heal based on stats
            session.FieldManager.BroadcastPacket(SkillDamagePacket.Heal(status, 50));
            fieldPlayer.Stats[StatId.Hp].Increase(50);
            session.Send(StatPacket.UpdateStats(fieldPlayer, StatId.Hp));
        }
        else
        {
            List <DamageHandler> damages = new();
            for (int i = 0; i < count; i++)
            {
                int entityId = packet.ReadInt();
                packet.ReadByte();

                IFieldActor <NpcMetadata> mob = session.FieldManager.State.Mobs.GetValueOrDefault(entityId);
                if (mob == null)
                {
                    continue;
                }

                DamageHandler damage = DamageHandler.CalculateDamage(fieldPlayer.SkillCast, fieldPlayer, mob, isCrit);

                mob.Damage(damage);
                // TODO: Move logic to Damage()
                session.FieldManager.BroadcastPacket(StatPacket.UpdateMobStats(mob));
                if (mob.IsDead)
                {
                    HandleMobKill(session, mob);
                }

                damages.Add(damage);

                // TODO: Check if the skill is a debuff for an entity
                SkillCast skillCast = fieldPlayer.SkillCast;
                if (skillCast.IsDebuffElement() || skillCast.IsDebuffToEntity() || skillCast.IsDebuffElement())
                {
                    Status status = new(fieldPlayer.SkillCast, mob.ObjectId, fieldPlayer.ObjectId, 1);
                    StatusHandler.Handle(session, status);
                }
            }

            session.FieldManager.BroadcastPacket(SkillDamagePacket.Damage(skillSN, attackCounter, position, rotation, fieldPlayer, damages));
        }
    }