Esempio n. 1
0
    def get(self):
        data = db.hgetall('status')
        date = datetime.datetime.strptime(data["utc_time"],
                                          '%d-%m-%y %H:%M:%S')
        data['utc_time'] = str(datetime.datetime.utcnow() - date)[:-7]
        l_mmo = Array('c', b'unreachable')
        p = Process(target=get_latency, args=(
            "XX:9091",
            l_mmo,
        ))
        p.start()
        p.join(4)
        if p.is_alive():
            p.terminate()
            p.join()
        mmo = {"Howob": l_mmo.value.decode()}
        l_rts = Array('c', b'unreachable')
        p2 = Process(target=get_latency, args=(
            "RTS",
            l_rts,
        ))
        p2.start()
        p2.join(4)
        if p2.is_alive():
            p2.terminate()
            p2.join()
        rts = {"Boomcraft": l_rts.value.decode()}

        data["latency"] = {}
        data["latency"].update(mmo)
        data["latency"].update(rts)
        return data, 200
Esempio n. 2
0
 def post(self):
     # print("no processed data receive : {}".format(request.data))
     # logging.info("post RTS")
     # logging.info(request.data)
     npc_quest = json.loads(db.hget('quests', NPC_UUID))
     args = parser.parse_args()
     if args.nbr_remnants:
         update = args.nbr_remnants
         data = json.loads(db.hget('characters', NPC_TRASH_UUID))
         data["character_last_position"] = data["character_last_position"]
         data["nbr_remnants"] = update
         key_to_delete = []
         players = db.hgetall('quests')
         for key in npc_quest:
             if (npc_quest[args.quest_key]["game_key"] == npc_quest[key]
                 ["game_key"]):
                 key_to_delete.append(key)
         for k, value in players.items():
             dict_value = literal_eval(value)
             for key in key_to_delete:
                 if key in dict_value:
                     del dict_value[key]
             db.hset('quests', k, json.dumps(dict_value))
         data["quest_key_1"] = key_to_delete[0]
         data["quest_key_2"] = key_to_delete[1]
         data_mq = {"call_type": 0, "from": "RTS", "payload": data}
         communication_core.rts_quest_add(data_mq)
         response = "monsters invocated"
     else:
         data = {}
         UUID = str(uuid4())
         data["quest_key"] = UUID
         data["team_key"] = args.team_key
         data["game_key"] = args.game_key
         data["quest_giver"] = NPC_UUID
         data["quest_name"] = args.quest_name
         data["quest_description"] = args.quest_description
         data["quest_gold"] = int(args.quest_gold)
         data["quest_type_key"] = 0
         data["quest_experience"] = int(args.quest_experience)
         data["quest_advancement"] = {
             "id": 12,
             "max_nbr": int(args.nbr_spawns_to_kill),
             "current": 0,
             "classe": 12
         }
         npc_quest[UUID] = data
         data["npc"] = json.loads(db.hget('characters', NPC_TRASH_UUID))
         data["npc"]["character_last_position"] = literal_eval(
             data["npc"]["character_last_position"])
         db.hset('quests', NPC_UUID, json.dumps(npc_quest))
         del data["team_key"]
         del data["game_key"]
         data_mq = {"call_type": 1, "from": "RTS", "payload": data}
         communication_core.rts_quest_add(data_mq)
         response = UUID
     # print(npc_quest)
     return response, 200
Esempio n. 3
0
 def get(self, UUID=None):
     if UUID:
         if int(UUID) == 99:
             data = dict(db.hgetall('classes'))
             response = dict()
             for key in data:
                 if (int(key) < 5):
                     response[key] = json.loads(data[str(key)])
         else:
             checkUUID(UUID)
             response = literal_eval(db.hget('classes',
                                             UUID))['class_attacks']
     else:
         response = dict(db.hgetall('classes'))
         for key in response:
             response[key] = json.loads(response[key])
         # print(response)
     return jsonify(response)
Esempio n. 4
0
 def get(self, UUID=None):
     if not UUID:
         responses = db.hgetall('quests')
         traited_responses = {}
         for key, value in responses.items():
             if db.hexists('accounts', key) == 0:
                 traited_responses[key] = literal_eval(responses[key])
     else:
         checkUUID(UUID)
         traited_responses = literal_eval(db.hget('quests', UUID))
     # print(traited_responses)
     return traited_responses, 200
Esempio n. 5
0
 def get(self, UUID=None):
     if not UUID:
         responses = db.hgetall('characters')
         traited_responses = {}
         for key, value in responses.items():
             dict_temp = literal_eval(responses[key])
             dict_temp['character_last_position'] = literal_eval(
                 dict_temp['character_last_position'])
             responses[key] = dict_temp
             if dict_temp['account_key'] == 0:
                 traited_responses[key] = responses[key]
     else:
         checkUUID(UUID, 'characters')
         response = db.hget('characters', UUID)
         response = literal_eval(response)
         response["character_last_position"] = literal_eval(
             response.get("character_last_position"))
         response["character_key"] = UUID
         traited_responses = response
     return traited_responses