Añadir Items en el Market

Alex

Miembro del equipo
Webdesigner
LV
58
 
Awards
38
Hola a todos,

Este es un método para poder añadir items en el Market, aun no probado.

Hay que descargar Python y Pymongo.

Una vez hecho abrir la consola Python y ejecutar este script:

import Pymongo
from Pymongo import MongoClient
from pprint import pprint
from bson.int64 import Int64
import copy

class Marketplace:

item_data = {
# weapons: index0 is used for price
"weapons" : [
[ 200000, 10413, 10613, 13313, 11213, 11363, 10213, 10013, 13213, 14413 ], # Bares
[ 200000, 10403, 10603, 13303, 11203, 11353, 10203, 10003, 13203, 14403 ], # Elsh
[ 120000, 10406, 10606, 13306, 11206, 11356, 10206, 10006, 13206, 14406 ], # Ain
[ 120000, 10405, 10605, 13305, 11205, 11355, 10205, 10005, 13205, 14405 ], # Azwell
[ 140000, 10471, 10671, 13371, 11222, 11372, 10271, 10071, 13271, 14471 ], # Styd
[ 150000, 10414, 10614, 13314, 11214, 11364, 10214, 10014, 13214, 14414 ], # Yuria
[ 150000, 10407, 10607, 13307, 11207, 11357, 10207, 10007, 13207, 14407 ], # Seleth
[ 200000, 10412, 10612, 13312, 11212, 11362, 10212, 10012, 13212, 14412 ], # Kalis
[ 250000, 10456, 10656, 13356, 11220, 11370, 10256, 10056, 13256, 14456 ], # Krea
[ 300000, 10457, 10657, 13357, 11221, 11371, 10257, 10057, 13257, 14457 ], # Rosar
[ 9000000, 10409, 10609, 13309, 11209, 11359, 10209, 10009, 13209, 14409 ], # Liverto
[ 90000000, 10410, 10610, 13310, 11210, 11360, 10210, 10010, 13210, 14410 ], # Kzarka
# Secondaries
#[ 10000, 10301, 13001, 10101, 10501, 10701, 13101, 14501, 14601, 11301 ], # t1
#[ 60000, 10302, 13002, 10104, 10502, 10702, 13102, 14502, 14602, 11302 ], # t2
[ 60000, 10303, 13003, 10102, 10503, 10705, 13104, 14503, 14603, 11303 ], # t3
[ 200000, 10304, 13004, 10103, 10504, 10704, 13103, 14504, 14604, 11304 ], # t4
[ 250000, 10305, 13005, 10105, 10505, 10703, 13105, 14505, 14605, 11305 ], # t5
[ 350000, 10324, 13024, 10124, 10724, 10524, 13124, 14524, 14624, 11324 ], # t6
[ 400000, 10325, 13025, 10125, 10525, 10725, 13125, 14525, 14625, 11325 ], # t7
[ 80000000, 10340, 13140, 14540, 10740, 10140, 14640, 10540, 13040, 11340 ], # t8 kutum
[ 90000000, 13038, 10338, 13138, 14538, 10738, 10138, 10138, 14638, 10538, 11338 ], # t9 nouver

# Awakened
[ 90000000, 14802, 14742, 14762, 14822, 14812, 14702, 14722, 14732, 14772, 14752, 14792, 14712, 14782, 14817 ], # dandelion

# Misusing the weapon structure here for non-stacking misc items
# because they are processed in the same way.
# Magic Crystals:
[ 5000, 15034, 15035, 15036, 15037, 15038, 15039, 15040, 15041, 15042, 15043, 15044, 15045 ], # white
[ 5000, 15001, 15002, 15003, 15004, 15005, 15006, 15007, 15008, 15009, 15010, 15011, 15012, 15013, 15014, 15015, 15016, 15017, 15018, 15019, 15020, 15027, 15028, 15029, 15030, 15031, 15033 ], # green
[ 250000, 15101, 15102, 15103, 15104, 15105, 15106, 15107, 15108, 15109, 15110, 15111, 15112, 15113, 15114, 15115, 15116, 15117, 15118, 15119, 15120, 15121, 15122, 15123, 15124, 15125, 15126, 15127, 15128, 15129, 15130, 15131, 15132, 15133, 15134, 15135, 15136, 15137, 15138, 15139, 15146, 15147, 15148, 15149, 15150, 15151, 15152, 15153, 15154 ], # blue
[ 1600000, 15021, 15022, 15023, 15024, 15025, 15026, 15032, 15201, 15202, 15203, 15204, 15205, 15206, 15207, 15208, 15209, 15210, 15211, 15212, 15213, 15214, 15215, 15216, 15217, 15218, 15219, 15220, 15221, 15222, 15223, 15224, 15606, 15607, 15608, 15609, 15610, 15611, 15612, 15613, 15614, 15615, 15616, 15617, 15618, 15619, 15620, 15621, 15622, 15623, 15624, 15625 ], # yellow
[ 15000000, 15501, 15502, 15503, 15504, 15505, 15601, 15602, 15603, 15604, 15605, 15606, 15626, 15627, 15628, 15629, 15630, 15631, 15632, 15633, 15634, 15635, 15636, 15637, 15638, 15639, 15640, 15649, 15650, 15651 ], # orange



# Summon Items 15226,
[ 100000, 40220 ], # Forbidden Book
[ 200000, 40218 ], # Ancient Relic Crystal shard
[ 250000, 40228 ], # Scroll written in ancient language

### Useful consumables ###
# Purified Water, Star Anise Tea
[ 1000, 6656, 9306 ],

# Dim Tree Armor, Red Nose Armor, Giath Hat, Muskan Shoe, Bheg Glove
[ 100000000, 11017, 11014, 11013, 11016, 11015 ],

## Crafting ##
[ 50000, 44195 ], # Memory Fragment
[ 100000, 4911, 4910 ], # grade 3 reform stones
[ 100000, 16001, 16002 ], # Black stones
[ 10000000, 16004, 16005 ], # Concentrated Black stones

# Accessories

# Riddell Earring
[ 900000, 11811 ],

# Shrine Guardian Token, Outlaw's Ring
[ 1500000, 12008, 12012 ],

# Blue Coral Ring, Blue Coral Earring, Ancient Weapon Core, Red Coral Ring, Scarla Necklace
[ 4500000, 12017, 11816, 12220, 12018, 11610 ],

# Belt of Shultz
[ 7000000, 12211 ],

# Necklace of Shultz, Red Coral Earring, Witch's Earring, Fugitive Khalk's Earring, Mark of Shadow
[ 12000000, 11631, 11817, 11808, 11827, 12007 ],

# Ancient Guardian's Seal
[ 18000000, 11613 ],

# Tree Spirit Belt
[ 35000000, 12210 ],

# Blue Whale Molar Earring
[ 40000000, 11815 ],

# Ring of Cadry Guardian, Ring of Crescent Guardian, Serap's Necklace
[ 45000000, 12032, 12031, 11628 ],

# Sicil's Necklace
[ 55000000, 11625 ],

# Basilisk's Belt
[ 70000000, 12230 ],

# Tungrad Earring, Ogre Ring, Laytenn's Power Stone
[ 90000000, 11828, 11607, 11630 ],

# Tungrad Necklace
[ 120000000, 11629 ],

],
# armor has a feature where chests are more expensive than other parts
"armor" : [ # price, hatID, chestID, gloveID, shoeID
[ 100000, 10813, 10814, 10815, 10816 ], # Taritas
[ 100000, 10821, 10822, 10823, 10824 ], # Talis
[ 250000, 10809, 10810, 10811, 10812 ], # Agerian
[ 330000, 11005, 11006, 11007, 11008 ], # Strength of Heve
[ 320000, 11001, 11002, 11003, 11004 ], # Hercules Might
[ 330000, 11009, 11010, 11011, 11012 ], # Luck Fortuna
[ 340000, 10817, 10818, 10819, 10820 ], # Zereth
[ 350000, 10933, 10934, 10935, 10936 ], # grunil
[ 200000, 10937, 10938, 10939, 10940 ], # Rocaba
],

# other have price as index0 and quantity as index 1
"other" : [
[ 100000, 9999, 16001, 16002 ], # Black stones
[ 10000000, 999, 16004, 16005 ], # Concentrated Black stones

]
}

base_item = {
"_id":Int64(10000002000000002),
"accountId": 2,
"marketRegistredDate": 1531821851,
"marketExpirationDate": 1832426651,
"revenue":0,
"totalCount":9999999,
"price":33333,
"territoryKey":0,
"item":{
"objectId": -1,
"itemId":10813,
"regionId":1,
"enchantLevel":0,
"count":9999,
"endurance":100,
"maxEndurance":100,
"expirationPeriod":-1,
"isVested":False,
"price":33333,
"alchemyStoneExp":0,
"colorPaletteType":0,
"jewels":[],
"colorPalettes":[]
}
}

base_master = {
"_id":Int64(10000002000000002),
"itemId":10813,
"itemEnchantLevel":0,
"itemMinPrice":100,
"itemMaxPrice":Int64(100000000000),
"marketSoldCount":0,
"marketMinPrice":100,
"marketMaxPrice":Int64(100000000000),
"marketPrice":33333
}

def __init__(self):
# Account ID in mongo account collection of the user who is
# "selling" everything that we are putting on the market. To create
# an account for this modify the Start64.bat to change the
# credentials and the change back to launch your main account.
self.account_id = 2

self.current_key = 0
self.market_items = []
self.master_items = []

def collectionsAreEmpty(self, db):
gs = db["gameserver"]
if "itemMarket" in gs.collection_names():
if gs["itemMarket"].count() > 0:
gs["itemMarket"].drop()
gs["itemMarket"].remove()

if gs["itemMarket"].count() > 0:
raise EnvironmentError("Script was unable to create an empty collection. You need to manually delete itemMarket and itemMarketMaster collections to run this script.")

if "itemMarketMaster" in gs.collection_names():
if gs["itemMarketMaster"].count() > 0:
gs["itemMarketMaster"].drop()
gs["itemMarketMaster"].remove()


def populate(self):
# if collections do not exist, create them
# if that fails, error out
# if collections exist and are empty, proceed
# if collections exist and are not empty, drop them
# if collections still exist and are not empty, error out

try:
db = MongoClient("localhost", 27017)
gameserver = db["gameserver"]

self.collectionsAreEmpty(db)

self.col_item_market = gameserver.itemMarket
self.col_master_item_market = db["gameserver"].masterItemMarket

self.buildArmor()
self.buildWeapons()
self.buildOther()
self.send_item_market()
self.send_item_master()
print("If you don't see any error messages, it probably worked")

except EnvironmentError as e:
print (e.args)

def getNewId(self):
self.current_key = self.current_key + 1
return Int64(1000000200000) + self.current_key

def addDupes(self, item_record, num_dupes):
for c in range(0, num_dupes):
new_clone_item = copy.deepcopy(item_record)
new_clone_item["_id"] = self.getNewId()
self.market_items.append(new_clone_item)

def buildArmor(self):
for idx in range(len(self.item_data["armor"])):
armor_set = self.item_data["armor"][idx]
price = armor_set[0]
armor_set.pop(0)

for idx2 in range(len(armor_set)):
new_item = copy.deepcopy(self.base_item)
new_item["_id"] = self.getNewId()
new_item["price"] = price
new_item["item"]["price"] = price
new_item["item"]["itemId"] = armor_set[idx2]
self.market_items.append(new_item)
#self.addDupes(new_item, 10)

new_master = copy.deepcopy(self.base_master)
new_master["_id"] = new_item["_id"]
new_master["itemId"] = armor_set[idx2]
new_master["marketPrice"] = price
self.master_items.append(new_master)

def buildWeapons(self):
for idx in range(len(self.item_data["weapons"])):
weapon_set = self.item_data["weapons"][idx]
price = weapon_set[0]
weapon_set.pop(0)

for idx2 in range(len(weapon_set)):
new_item = copy.deepcopy(self.base_item)
new_item["_id"] = self.getNewId()
new_item["price"] = price
new_item["item"]["price"] = price
new_item["item"]["itemId"] = weapon_set[idx2]
self.market_items.append(new_item)
#self.addDupes(new_item, 10)

new_master = copy.deepcopy(self.base_master)
new_master["_id"] = new_item["_id"]
new_master["itemId"] = weapon_set[idx2]
new_master["marketPrice"] = price
self.master_items.append(new_master)

def buildOther(self):
pass

def send_item_market(self):
for idx in range(len(self.market_items)):
result = self.col_item_market.insert_one(self.market_items[idx])
if not result.acknowledged:
pprint(market_items[idx])
raise ConnectionError("Insert failed")

def send_item_master(self):
for idx in range(len(self.master_items)):
result = self.col_master_item_market.insert_one(self.master_items[idx])
if not result.acknowledged:
pprint(master_items[idx])
raise ConnectionError("Insert failed")

if __name__ == "__main__":
mrkt = Marketplace()
mrkt.populate()

Esto llenará el mercado con la mayor parte de las armas , armaduras y accesorios conjuntos en el juego. Nota de que a pesar de que es el código para soltar los mongo colecciones antes de ejecutar secuencias de comandos , que no parece funcionar.
Solo debería necesitar ejecutar esto una vez, pero si desea modificar el script para agregar más elementos o lo que sea, probablemente necesitará eliminar manualmente las colecciones itemMarket y itemMarketMaster de la base de datos del servidor de juegos de mongo .
 
Arriba