오탈자 수정및 규칙 변경
This commit is contained in:
parent
0945f757c0
commit
44f1327bd2
|
|
@ -1,10 +1,13 @@
|
|||
using Server.SQL;
|
||||
using NLog;
|
||||
using Server.SQL;
|
||||
using Server.System;
|
||||
|
||||
namespace Server.Manager
|
||||
{
|
||||
public class ItemManager
|
||||
{
|
||||
private static readonly NLog.ILogger logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
User user;
|
||||
|
||||
public ItemBox box;
|
||||
|
|
@ -30,33 +33,45 @@ namespace Server.Manager
|
|||
switch (rewardData.reward_item_type)
|
||||
{
|
||||
case eRewardItemType.gold:
|
||||
user.gold += rewardData.return_item;
|
||||
user.gold += rewardData.return_count;
|
||||
break;
|
||||
case eRewardItemType.freecash:
|
||||
user.free_cash += rewardData.return_item;
|
||||
user.free_cash += rewardData.return_count;
|
||||
break;
|
||||
case eRewardItemType.paycash:
|
||||
user.pay_cash += rewardData.return_item;
|
||||
user.pay_cash += rewardData.return_count;
|
||||
break;
|
||||
case eRewardItemType.character:
|
||||
for (int n = 0; n < rewardData.return_count; n++)
|
||||
{
|
||||
DeckUnitInfo deckUnitInfo = new DeckUnitInfo();
|
||||
deckUnitInfo.user_id = user.id;
|
||||
deckUnitInfo.unit_id = rewardData.return_item;
|
||||
box.Add(deckUnitInfo);
|
||||
}
|
||||
break;
|
||||
case eRewardItemType.equipment:
|
||||
Random rand = new Random();
|
||||
for (int n = 0; n < rewardData.return_count; n++)
|
||||
{
|
||||
Equipment equipment = new Equipment();
|
||||
equipment.user_id = user.id;
|
||||
equipment.equip_unit = 0;
|
||||
equipment.rand_stats = (new Random()).Next(5);
|
||||
equipment.rand_stats = rand.Next(5);
|
||||
equipment.equipment_data_id = rewardData.return_item;
|
||||
box.Add(equipment);
|
||||
}
|
||||
break;
|
||||
case eRewardItemType.consumable:
|
||||
//소모품 만들고 넣기
|
||||
ConsumableItem consumableItem = new ConsumableItem();
|
||||
consumableItem.user_id = user.id;
|
||||
consumableItem.consumable_item_data_id = rewardData.return_item;
|
||||
consumableItem.count = rewardData.return_count;
|
||||
box.Add(consumableItem);
|
||||
break;
|
||||
case eRewardItemType.etc:
|
||||
//기타아이탬 만들고 넣기
|
||||
logger.Info("아직 개발중인 시스템");
|
||||
break;
|
||||
default:
|
||||
throw new RuntimeException("Not case", Error.nodata);
|
||||
|
|
@ -72,15 +87,21 @@ namespace Server.Manager
|
|||
|
||||
public class ItemBox
|
||||
{
|
||||
//유닛
|
||||
List<DeckUnitInfo> _deckUnitInfo;
|
||||
public List<DeckUnitInfo> deckUnitInfo { get { return _deckUnitInfo; } }
|
||||
|
||||
public List<DeckUnitInfo> addDeckUnitInfo;
|
||||
|
||||
//장비
|
||||
List<Equipment> _equipment;
|
||||
public List<Equipment> equipment { get { return _equipment; } }
|
||||
public List<Equipment> addEquipment;
|
||||
|
||||
//소모품
|
||||
List<ConsumableItem> _consumableItem;
|
||||
public List<ConsumableItem> consumableItem { get { return _consumableItem; } }
|
||||
public List<ConsumableItem> addConsumableItem;
|
||||
|
||||
public ItemBox(User user)
|
||||
{
|
||||
_deckUnitInfo = Statics.deckUnitInfoSQL.SelectUid(user.id);
|
||||
|
|
@ -133,13 +154,61 @@ namespace Server.Manager
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
public bool Add(List<Equipment> items)
|
||||
{
|
||||
_equipment.AddRange(items);
|
||||
addEquipment.AddRange(items);
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Add(ConsumableItem item)
|
||||
{
|
||||
int index = _consumableItem.FindIndex(n => n.consumable_item_data_id == item.consumable_item_data_id);
|
||||
int addIndex = addConsumableItem.FindIndex(n => n.consumable_item_data_id == item.consumable_item_data_id);
|
||||
if (index == -1)
|
||||
{
|
||||
_consumableItem.Add(item);
|
||||
}
|
||||
else
|
||||
{
|
||||
_consumableItem[index].count += item.count;
|
||||
}
|
||||
if (addIndex == -1)
|
||||
{
|
||||
addConsumableItem.Add(item);
|
||||
}
|
||||
else
|
||||
{
|
||||
addConsumableItem[index].count += item.count;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Add(List<ConsumableItem> items)
|
||||
{
|
||||
foreach(ConsumableItem item in items)
|
||||
{
|
||||
int index = _consumableItem.FindIndex(n => n.consumable_item_data_id == item.consumable_item_data_id);
|
||||
int addIndex = addConsumableItem.FindIndex(n => n.consumable_item_data_id == item.consumable_item_data_id);
|
||||
if (index == -1)
|
||||
{
|
||||
_consumableItem.Add(item);
|
||||
}
|
||||
else
|
||||
{
|
||||
_consumableItem[index].count += item.count;
|
||||
}
|
||||
if (addIndex == -1)
|
||||
{
|
||||
addConsumableItem.Add(item);
|
||||
}
|
||||
else
|
||||
{
|
||||
addConsumableItem[index].count += item.count;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,37 @@
|
|||
using Microsoft.EntityFrameworkCore;
|
||||
using Newtonsoft.Json;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Server.SQL
|
||||
{
|
||||
[Table("consumable_item", Schema = "gamedb")]
|
||||
public class ConsumableItem
|
||||
{
|
||||
public long id { get; set; }
|
||||
[JsonIgnore]
|
||||
public long user_id { get; set; }
|
||||
public long consumable_item_data_id { get; set; }
|
||||
|
||||
public int count { get; set; }
|
||||
}
|
||||
|
||||
public class ConsumableItemSQL : SQL<ConsumableItem>
|
||||
{
|
||||
public override DbSet<ConsumableItem> table { get; set; }
|
||||
|
||||
public void Update(ConsumableItem consumableItem)
|
||||
{
|
||||
table.Update(consumableItem);
|
||||
}
|
||||
|
||||
public override List<ConsumableItem> SelectUid(long user_id)
|
||||
{
|
||||
return table.Where(data => data.user_id == user_id).ToList();
|
||||
}
|
||||
|
||||
public ConsumableItem SelectItem(long user_id, long consumable_item_id)
|
||||
{
|
||||
return table.FirstOrDefault(data => (data.user_id == user_id) && (data.id == consumable_item_id));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -34,15 +34,17 @@ namespace Server.SQL
|
|||
{
|
||||
return consumableItemData.Values.ToList();
|
||||
}
|
||||
public void init(sheet data)
|
||||
public void init(Sheet data)
|
||||
{
|
||||
this.consumableItemData = new Dictionary<long, ConsumableItemData>();
|
||||
foreach (var item in data.dicViewer)
|
||||
{
|
||||
//ConsumableItemData ConsumableItemData = new ConsumableItemData();
|
||||
//ConsumableItemData.index = item.Key;
|
||||
//ConsumableItemData.part = (int)item.Value["part"];
|
||||
//this.ConsumableItemData.Add(item.Key, ConsumableItemData);
|
||||
ConsumableItemData consumableItemData = new ConsumableItemData();
|
||||
consumableItemData.index = item.Key;
|
||||
consumableItemData.name = (string)item.Value["name"];
|
||||
consumableItemData.item_type = (eItemType)item.Value["item_type"];
|
||||
consumableItemData.reward = (string)item.Value["reward"];
|
||||
this.consumableItemData.Add(item.Key, consumableItemData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ namespace Server.SQL
|
|||
public class DeckUnitInfo
|
||||
{
|
||||
public long id { get; set; }
|
||||
public long unit_id { get; set; }
|
||||
public long unit_id { get; set; }//네이밍 변경할것 unit_id > unit_data_id
|
||||
[JsonIgnore]
|
||||
public long user_id { get; set; }
|
||||
public long equip0_id { get; set; }
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ namespace Server.SQL
|
|||
public long index { get; set; }
|
||||
public eRewardItemType reward_item_type { get; set; }
|
||||
public long return_item { get; set; }
|
||||
public int return_count { get; set; }
|
||||
}
|
||||
|
||||
public enum eRewardItemType
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ namespace Server.Service
|
|||
private void SaveSQL(ItemManager item)
|
||||
{
|
||||
Statics.userSQL.SaveChanges();
|
||||
item.SaveSQL();
|
||||
item.box.SaveSQL();
|
||||
}
|
||||
|
||||
public override string Process()
|
||||
|
|
|
|||
Loading…
Reference in New Issue