public void TestGameDataSet(string mapInfoFilePath, GameDataSet expectedDataSet) { using var mapInfoStream = File.OpenRead(mapInfoFilePath); var mapInfo = MapInfo.Parse(mapInfoStream); Assert.AreEqual(expectedDataSet, mapInfo.GameDataSet); }
private void AddList(GameDataSet dataSet, GameDataType dataType, string csvString) { List <string[]> csvDataList = CsvHelper.FormatCsvToStringArrayList(csvString); switch (dataType) { case GameDataType.USER_ITEM: foreach (string[] data in csvDataList) { if (data == csvDataList[0]) { continue; } dataSet.UserItemList.Add(new UserItem(int.Parse(data[0]), int.Parse(data[1]), Convert.ToBoolean(data[2]))); } break; case GameDataType.USER_PARAMETER: foreach (string[] data in csvDataList) { if (data == csvDataList[0]) { continue; } dataSet.UserParameterList.Add(new UserParameter(int.Parse(data[0]), int.Parse(data[1]), data[2])); } break; default: break; } }
private void ShowSchemaButton_Click(object sender, EventArgs e) { StringWriter swXML = new StringWriter(); GameDataSet.WriteXmlSchema(swXML); textBox1.Text = swXML.ToString(); }
public GameDataSet ReadData() { GameDataSet dataSet = new GameDataSet(); AddList(dataSet, GameDataType.USER_ITEM, TextFileHelper.Read(Const.Path.GameData.userItem)); AddList(dataSet, GameDataType.USER_PARAMETER, TextFileHelper.Read(Const.Path.GameData.userParameter)); return(dataSet); }
public void TestGameDataSet(string mapInfoFilePath, GameDataSet expectedDataSet) { using var mapInfoStream = File.OpenRead(mapInfoFilePath); using var mapInfoReader = new BinaryReader(mapInfoStream); var mapInfo = mapInfoReader.ReadMapInfo(); Assert.AreEqual(expectedDataSet, mapInfo.GameDataSet); }
private void ReadXmlButton_Click(object sender, EventArgs e) { string filePath = @"C:\Users\Simone\Source\Repos\.NET\Blackjack\Blackjack\XML\games.xml"; GameDataSet.ReadXml(filePath); dataGridView1.DataSource = GameDataSet; dataGridView1.DataMember = "game"; }
public async Task <GameDataSet> CreateGameSet( int nvn, string HostId, string DuelId, List <CharCardSet> HostCardList = null, List <CharCardSet> DuelerCardList = null, List <EventCard> HostECList = null, List <EventCard> DuelerECList = null) { // if (RoomConn.CurrentRoom == null)throw new System.Exception("NO_ROOM_EXIST"); if (RoomKey == null) { throw new System.Exception("NO_ROOM_KEY"); } if (GDSClient == null) { throw new System.Exception("NO_CLIENT_EXIST"); } if (CurrentGS != null) { return(CurrentGS); } try { var req = new GDCreateReq { RoomKey = RoomKey, HostId = HostId, DuelerId = DuelId, Nvn = nvn, }; if (HostCardList != null) { req.HostCardDeck.AddRange(HostCardList); } if (DuelerCardList != null) { req.DuelCardDeck.AddRange(DuelerCardList); } if (HostECList != null) { req.HostExtraEc.AddRange(HostECList); } if (DuelerECList != null) { req.DuelExtraEc.AddRange(DuelerECList); } var tmpGameSet = await GDSClient.CreateGameAsync(req); Debug.Log($"{tmpGameSet.CurrPhase}"); CurrentGS = tmpGameSet; return(CurrentGS); } catch (RpcException) { throw; } }
public List <Item> getWinItemList(GameDataSet gameDataSet) { List <Item> itemList = new List <Item>(); var winNode = getWinNode(); var itemActionList = winNode.actionList.Where(x => x.actionType == NodeActionType.AddItem); foreach (var itemAction in itemActionList) { itemList.Add(ItemFactory.getItemFromIndex(itemAction.index, gameDataSet)); } return(itemList); }
public GameDataSet CreateInitialData() { GameDataSet dataSet = new GameDataSet(); foreach (Item item in MasterDataManager.Instance.MasterDataSet.ItemList) { dataSet.UserItemList.Add(new UserItem(dataSet.UserItemList.Count, item.Id, item.InitialIsOwned)); } foreach (Parameter param in MasterDataManager.Instance.MasterDataSet.ParameterList) { dataSet.UserParameterList.Add(new UserParameter(dataSet.UserParameterList.Count, param.Id, param.InitialValue)); } SaveData(dataSet); return(dataSet); }
public void loadGameData() { gameDataSet = new GameDataSet(); gameDataSet.itemDataDictionary = getDataObjectDictionary("Data/Items", typeof(ItemData)).ToDictionary(x => x.Key, x => (ItemData)x.Value); gameDataSet.usableItemDataDictionary = getDataObjectDictionary("Data/UsableItems", typeof(UsableItemData)).ToDictionary(x => x.Key, x => (UsableItemData)x.Value); gameDataSet.weaponDataDictionary = getDataObjectDictionary("Data/Weapons", typeof(WeaponData)).ToDictionary(x => x.Key, x => (WeaponData)x.Value); gameDataSet.rangedWeaponDataDictionary = getDataObjectDictionary("Data/RangedWeapons", typeof(RangedWeaponData)).ToDictionary(x => x.Key, x => (RangedWeaponData)x.Value); gameDataSet.ammoDataDictionary = getDataObjectDictionary("Data/Ammo", typeof(AmmoData)).ToDictionary(x => x.Key, x => (AmmoData)x.Value); gameDataSet.armorDataDictionary = getDataObjectDictionary("Data/Armors", typeof(ArmorData)).ToDictionary(x => x.Key, x => (ArmorData)x.Value); gameDataSet.effectDataDictionary = getDataObjectDictionary("Data/Effects", typeof(EffectData)).ToDictionary(x => x.Key, x => (EffectData)x.Value); gameDataSet.abilityDataDictionary = getDataObjectDictionary("Data/Abilities", typeof(AbilityData)).ToDictionary(x => x.Key, x => (AbilityData)x.Value); gameDataSet.gameCharacterDataDictionary = getDataObjectDictionary("Data/GameCharacters", typeof(GameCharacterData)).ToDictionary(x => x.Key, x => (GameCharacterData)x.Value); gameDataSet.talentTreeDataDictionary = getDataObjectDictionary("Data/TalentTree", typeof(TalentTreeData)).ToDictionary(x => x.Key, x => (TalentTreeData)x.Value); }
private StoreItem getSellItem(long itemID, float priceAdjustment, int count, GameDataSet gameDataSet) { StoreItem storeItem = null; Item i = ItemFactory.getItemFromIndex(itemID, gameDataSet); if (i != null) { storeItem = new StoreItem(); storeItem.item = i; storeItem.count = count; storeItem.price = (long)Math.Round(i.price * priceAdjustment); storeItem.selected = 1; return(storeItem); } return(storeItem); }
public void LoadGameData(GameDataSet ds, LogRecorderInterface log) { try { ds.Clear(); using (SQLiteDataAdapter adpt = new SQLiteDataAdapter("SELECT * FROM HashList", GetConnection())) adpt.Fill(ds.HashList); using (SQLiteDataAdapter adpt = new SQLiteDataAdapter("SELECT * FROM HardPointList", GetConnection())) adpt.Fill(ds.HardPointList); using (SQLiteDataAdapter adpt = new SQLiteDataAdapter("SELECT * FROM EquipInfoList", GetConnection())) adpt.Fill(ds.EquipInfoList); using (SQLiteDataAdapter adpt = new SQLiteDataAdapter("SELECT * FROM ShipInfoList", GetConnection())) adpt.Fill(ds.ShipInfoList); } catch (Exception e) { log.AddLog(String.Format("Error '{0}' when updating db", e.Message)); } }
//given a gameDataSet, and global flags, return the list of items (and prices) sold //dont return items with 0 price (specials, etc) public List <StoreItem> getSellList(GameDataSet gameDataSet, Random r) { List <StoreItem> storeList = new List <StoreItem>(); var infoNode = treeNodeDictionary[1]; foreach (var branch in infoNode.getBranchList(this)) { StoreTreeNode storeNode = (StoreTreeNode)this.getNode(branch.linkIndex); if (storeNode.content.nodeType == StoreNodeType.ItemClass) { storeList.AddRange(getSellItemTypeList(storeNode.content.itemType, storeNode.content.sellPrice, storeNode.content.count, storeNode.content.linkIndex, gameDataSet, r)); } else if (storeNode.content.nodeType == StoreNodeType.ItemIndex) { storeList.Add(getSellItem(storeNode.content.linkIndex, storeNode.content.sellPrice, storeNode.content.count, gameDataSet)); } } return(storeList); }
private List <StoreItem> getStoreItemListFromItemIdList(List <long> itemIdList, GameDataSet gameDataSet, int count, float priceAdjustment) { List <StoreItem> storeItemList = new List <StoreItem>(); foreach (long id in itemIdList) { var item = ItemFactory.getItemFromIndex(id, gameDataSet); if (item.price > 0) { StoreItem tempStoreItem = new StoreItem(); tempStoreItem.item = item; tempStoreItem.count = count; tempStoreItem.price = (long)Math.Round(tempStoreItem.item.price * priceAdjustment); tempStoreItem.selected = 1; storeItemList.Add(tempStoreItem); } } return(storeItemList); }
public async Task <GameDataSet> GetGameData(string roomKey, bool isWatcher) { if (GDSClient == null) { throw new System.Exception("NO_CLIENT_EXIST"); } // if (RoomKey == null || RoomKey == "")throw new System.Exception("NO_ROOM_KEY"); try { var req = new GDGetInfoReq { RoomKey = roomKey == null ? RoomKey : roomKey, IsWatcher = isWatcher, }; var tmpGameSet = await GDSClient.GetGameDataAsync(req); CurrentGS = tmpGameSet; return(CurrentGS); } catch (RpcException) { throw; } }
//lookup the item in the store list and return the price, otherwise default to .5f public long getBuyPrice(Item i, GameDataSet gameDataSet) { float buyPrice = 0.0f; var infoNode = treeNodeDictionary[1]; List <StoreTreeNode> storeNodeList = new List <StoreTreeNode>(); foreach (var branch in infoNode.getBranchList(this)) { var storeNode = (StoreTreeNode)this.getNode(branch.linkIndex); if (storeNode.content.nodeType == StoreNodeType.ItemIndex) { if (storeNode.content.linkIndex == i.ID) { if (storeNode.content.buyPrice > buyPrice) { buyPrice = storeNode.content.buyPrice; } } } else if (storeNode.content.nodeType == StoreNodeType.ItemClass) { if (storeNode.content.itemType == i.type && i.price <= storeNode.content.linkIndex) { if (storeNode.content.buyPrice > buyPrice) { buyPrice = storeNode.content.buyPrice; } } } } if (buyPrice < .5) { buyPrice = .5f; } return((long)Math.Round(i.price * buyPrice)); }
public void CommitGameData(GameDataSet ds, LogRecorderInterface log) { try { BeginTransaction(); using (SQLiteDataAdapter adpt = new SQLiteDataAdapter("SELECT * FROM HashList", GetConnection())) { SQLiteCommandBuilder builder = new SQLiteCommandBuilder(adpt); builder.ConflictOption = ConflictOption.OverwriteChanges; adpt.Update(ds.HashList); } using (SQLiteDataAdapter adpt = new SQLiteDataAdapter("SELECT * FROM HardPointList", GetConnection())) { SQLiteCommandBuilder builder = new SQLiteCommandBuilder(adpt); builder.ConflictOption = ConflictOption.OverwriteChanges; adpt.Update(ds.HardPointList); } using (SQLiteDataAdapter adpt = new SQLiteDataAdapter("SELECT * FROM EquipInfoList", GetConnection())) { SQLiteCommandBuilder builder = new SQLiteCommandBuilder(adpt); builder.ConflictOption = ConflictOption.OverwriteChanges; adpt.Update(ds.EquipInfoList); } using (SQLiteDataAdapter adpt = new SQLiteDataAdapter("SELECT * FROM ShipInfoList", GetConnection())) { SQLiteCommandBuilder builder = new SQLiteCommandBuilder(adpt); builder.ConflictOption = ConflictOption.OverwriteChanges; adpt.Update(ds.ShipInfoList); } EndTransaction(); } catch (Exception e) { log.AddLog(String.Format("Error '{0}' when updating db", e.Message)); } }
/// <summary> /// Scans the specified directory and recursively search for ini files that appear to contain /// hashcodes. /// </summary> /// <param name="flDataPath"></param> /// <param name="iniFilePath"></param> /// <remarks>Not used any more</remarks> private void ScanForHashCodes(GameDataSet dataStore, string flDataPath, BackgroundWorker bgw, LogRecorderInterface log) { // Scan the ini files. string[] iniFiles = Directory.GetFiles(flDataPath, "*.ini"); for (int i=0; i<iniFiles.Length; i++) { if (bgw.CancellationPending) return; string filePath = iniFiles[i]; bgw.ReportProgress(((i * 100) / iniFiles.Length), "Scanning " + filePath.Substring(flDataPath.Length + 1) + "..."); try { FLDataFile ini = new FLDataFile(filePath, true); foreach (FLDataFile.Section section in ini.sections) { foreach (FLDataFile.Setting e in section.settings) { if (e.NumValues() == 0) continue; string st = e.settingName.ToLowerInvariant(); if (st == "nickname" || st == "archetype" || st == "loadout" || st == "explosion_arch" || st == "fuse" || st == "zone" || st == "name" || st == "room" || st == "prop" || st == "msg_id_prefix" || st == "npc") { string nickName = e.Str(0); uint hashU = FLUtility.CreateID(nickName.ToLowerInvariant()); GameDataSet.HashListRow conflictingEntry = dataStore.HashList.FindByItemHash(hashU); if (conflictingEntry == null) { string keys = hashU.ToString() + " 0x" + hashU.ToString("X"); dataStore.HashList.AddHashListRow(hashU, nickName, GAMEDATA_GEN, "", "", "", "", "", keys); } } /* for (int j = 0; j < e.NumValues(); j++) { string nickName = e.Str(j); uint hashU = FLUtility.CreateID(nickName.ToLowerInvariant()); string keys = hashU.ToString() + " 0x" + hashU.ToString("X"); GameDataSet.HashListRow conflictingEntry = dataStore.HashList.FindByItemHash(hashU); if (conflictingEntry == null) { dataStore.HashList.AddHashListRow(hashU, nickName, GAMEDATA_GEN, "", "", "", "", ""); } } */ } } } catch (Exception ex) { log.AddLog(String.Format("Error '{0}' when scanning {1}", ex.Message, filePath)); } } // Recurse through subdirectories. string[] dataDirs = Directory.GetDirectories(flDataPath); for (int i = 0; i < dataDirs.Length; i++ ) { ScanForHashCodes(dataStore, dataDirs[i], bgw, log); } }
public void CreateInitialData() { GameDataLoader dataLoader = new GameDataLoader(); GameDataSet = dataLoader.CreateInitialData(); }
public void UpdateData() { GameDataLoader dataLoader = new GameDataLoader(); GameDataSet = dataLoader.ReadData(); }
public FLGameData() { DataStore = new GameDataSet(); }
//returning a random list of items of type at less than rarityIndex (price) private List <StoreItem> getSellItemTypeList(ItemType type, float priceAdjustment, int count, long rarityIndex, GameDataSet gameDataSet, Random r) { List <StoreItem> storeItemList = new List <StoreItem>(); var itemCount = r.Next(9) + 1; //TODO: Do we want this hardcoded here? switch (type) { case ItemType.Weapon: List <long> weaponIdList = gameDataSet.weaponDataDictionary.Where(x => x.Value.price <= rarityIndex).Select(x => x.Key).OrderBy(x => r.Next()).Take(itemCount).ToList(); storeItemList.AddRange(getStoreItemListFromItemIdList(weaponIdList, gameDataSet, count, priceAdjustment)); break; case ItemType.Ammo: List <long> ammoIdList = gameDataSet.ammoDataDictionary.Where(x => x.Value.price <= rarityIndex).Select(x => x.Key).OrderBy(x => r.Next()).Take(itemCount).ToList(); storeItemList.AddRange(getStoreItemListFromItemIdList(ammoIdList, gameDataSet, count, priceAdjustment)); break; case ItemType.Armor: List <long> armorIdList = gameDataSet.armorDataDictionary.Where(x => x.Value.price <= rarityIndex).Select(x => x.Key).OrderBy(x => r.Next()).Take(itemCount).ToList(); storeItemList.AddRange(getStoreItemListFromItemIdList(armorIdList, gameDataSet, count, priceAdjustment)); break; case ItemType.Potion: List <long> potionIdList = gameDataSet.usableItemDataDictionary.Where(x => x.Value.price <= rarityIndex && x.Value.type == ItemType.Potion).Select(x => x.Key).OrderBy(x => r.Next()).Take(itemCount).ToList(); storeItemList.AddRange(getStoreItemListFromItemIdList(potionIdList, gameDataSet, count, priceAdjustment)); break; case ItemType.Thrown: List <long> thrownIdList = gameDataSet.usableItemDataDictionary.Where(x => x.Value.price <= rarityIndex && x.Value.type == ItemType.Thrown).Select(x => x.Key).OrderBy(x => r.Next()).Take(itemCount).ToList(); storeItemList.AddRange(getStoreItemListFromItemIdList(thrownIdList, gameDataSet, count, priceAdjustment)); break; case ItemType.Wand: List <long> wandIdList = gameDataSet.usableItemDataDictionary.Where(x => x.Value.price <= rarityIndex && x.Value.type == ItemType.Wand).Select(x => x.Key).OrderBy(x => r.Next()).Take(itemCount).ToList(); storeItemList.AddRange(getStoreItemListFromItemIdList(wandIdList, gameDataSet, count, priceAdjustment)); break; default: break; } return(storeItemList); }
public static void SaveData(GameDataSet dataSet) { TextFileHelper.Write(Const.Path.GameData.userItem, CsvHelper.FormatListToCsv(dataSet.UserItemList)); TextFileHelper.Write(Const.Path.GameData.userParameter, CsvHelper.FormatListToCsv(dataSet.UserParameterList)); }
private bool AddGameData(GameDataSet.HashListDataTable items, FLDataFile.Section section, string gameDataType, bool ignoreEntriesWithNoIds) { string nickName = section.GetSetting("nickname").Str(0); string stIDSName = GetIDSParm(section, "ids_name"); if (stIDSName == "") stIDSName = GetIDSParm(section, "strid_name"); if (ignoreEntriesWithNoIds && stIDSName == "") return false; uint hash = FLUtility.CreateID(nickName.ToLowerInvariant()); if (gameDataType == GAMEDATA_FACTIONS) hash = FLUtility.CreateFactionID(nickName); GameDataSet.HashListRow conflictingHashEntry = items.FindByItemHash(hash); if (conflictingHashEntry != null) return false; string stIDSInfo = GetIDSParm(section, "ids_info"); string stIDSInfo1 = GetIDSParm(section, "ids_info1"); if (stIDSInfo1 == "") stIDSInfo1 = GetIDSParm(section, "ids_short_name"); string stIDSInfo2 = GetIDSParm(section, "ids_info2"); string stIDSInfo3 = GetIDSParm(section, "ids_info3"); string keys = hash.ToString() + " 0x" + hash.ToString("X"); items.AddHashListRow(hash, nickName, gameDataType, stIDSName, stIDSInfo, stIDSInfo1, stIDSInfo2, stIDSInfo3, keys); return true; }
/// <summary> /// Load room hash codes from base ini data. /// </summary> /// <param name="baseIniPath"></param> private void LoadRoomData(GameDataSet dataStore, string baseNick, string baseIniPath) { FLDataFile iniRoom = new FLDataFile(baseIniPath, true); foreach (FLDataFile.Section section in iniRoom.sections) { if (section.sectionName.ToLowerInvariant() != "room") continue; string locationNick = FLUtility.CreateID(baseNick.ToLowerInvariant()).ToString("x") + "_" + section.GetSetting("nickname").Str(0).ToLowerInvariant(); uint hashU = FLUtility.CreateID(locationNick.ToLowerInvariant()); string keys = hashU.ToString() + " 0x" + hashU.ToString("X"); GameDataSet.HashListRow conflictingEntry = dataStore.HashList.FindByItemHash(hashU); if (conflictingEntry == null) { dataStore.HashList.AddHashListRow(hashU, locationNick, GAMEDATA_ROOM, GetItemDescByNickNameX(baseNick), "", "", "", "", keys); } } }
/// <summary> /// Load an ion cross game data file that has a nickname key /// </summary> /// <param name="items">The database to copy data into</param> /// <param name="ioncrossDir">The file </param> /// <param name="hashFile"></param> private void LoadIonCrossNickNameDesc(GameDataSet.HashListDataTable items, string filePath, LogRecorderInterface log, bool isFaction) { try { FLDataFile ini = new FLDataFile(filePath, false); foreach (FLDataFile.Section s in ini.sections) { foreach (FLDataFile.Setting setting in s.settings) { try { GameDataSet.HashListRow itemRecord = GetItemByNickName(setting.settingName.ToLowerInvariant()); if (isFaction) itemRecord = GetItemByFactionNickName(setting.settingName.ToLowerInvariant()); if (itemRecord != null) { if (setting.NumValues() > 0) itemRecord.IDSName = setting.Str(0); } } catch (Exception ex) { log.AddLog(String.Format("Error '{0}' when reading {1}", ex.Message, setting.desc)); } } } } catch (Exception ex) { log.AddLog(String.Format("Error '{0}' when reading {1}", ex.Message, filePath)); } }
/// <summary> /// Load a ion cross game data file that has a hash key /// </summary> /// <param name="items">The database to copy data into</param> /// <param name="ioncrossDir">The file </param> /// <param name="hashFile"></param> private void LoadIonCrossHashDesc(GameDataSet.HashListDataTable items, string filePath, LogRecorderInterface log) { try { FLDataFile ini = new FLDataFile(filePath, true); foreach (FLDataFile.Section s in ini.sections) { foreach (FLDataFile.Setting setting in s.settings) { try { GameDataSet.HashListRow itemRecord = GetItemByNickName(setting.settingName); if (itemRecord == null) itemRecord = GetItemByHash(Convert.ToUInt32(setting.settingName)); if (itemRecord != null) { if (setting.NumValues() > 1) itemRecord.IDSName = setting.Str(1); else if (setting.NumValues() > 0) itemRecord.IDSName = setting.Str(0); } } catch (Exception ex) { log.AddLog(String.Format("Error '{0}' when reading {1}", ex.Message, setting.desc)); } } } } catch (Exception ex) { log.AddLog(String.Format("Error '{0}' when reading {1}", ex.Message, filePath)); } }