public void Learn(int skillId) { PlayerState playerState = playerStateStorage.Get(); List <int> currentSkillIds = playerState.SkillIds; for (int i = 0; i < currentSkillIds.Count; ++i) { var currentSkillId = currentSkillIds[i]; if (skillStorage.Get(skillId).BaseId != skillStorage.Get(currentSkillId).BaseId) { continue; } playerState.RemoveSkill(currentSkillId); break; } playerState.AddSkill(skillId); --playerState.AvailableSkillPointsCount; playerStateStorage.Save(playerState); }