Beispiel #1
0
 async def create_random_item(self,
                              minstat,
                              maxstat,
                              minvalue,
                              maxvalue,
                              owner,
                              insert=True):
     owner = owner.id if isinstance(owner, (discord.User,
                                            discord.Member)) else owner
     item = {}
     item["owner"] = owner
     type_ = random.choice(self.config.item_types)
     if type_ in ["Scythe", "Bow", "Howlet"]:
         item["hand"] = "both"
     elif type_ in ["Spear", "Wand"]:
         item["hand"] = "right"
     elif type_ == "Shield":
         item["hand"] = "left"
     else:
         item["hand"] = "any"
     item["type_"] = type_
     item["damage"] = random.randint(minstat,
                                     maxstat) if type_ != "Shield" else 0
     item["armor"] = random.randint(minstat,
                                    maxstat) if type_ == "Shield" else 0
     item["value"] = random.randint(minvalue, maxvalue)
     item["name"] = fn.weapon_name(type_)
     if item["hand"] == "both":
         item["damage"] = round(
             item["damage"] *
             1.5)  # both hands = higher damage, else they would be worse
     if insert:
         return await self.create_item(**item)
     return item
Beispiel #2
0
 async def create_random_item(self,
                              minstat,
                              maxstat,
                              minvalue,
                              maxvalue,
                              owner,
                              insert=True,
                              conn=None):
     owner = owner.id if isinstance(owner, (discord.User,
                                            discord.Member)) else owner
     item = {}
     item["owner"] = owner
     type_ = random.choice(ALL_ITEM_TYPES)
     hand = type_.get_hand()
     item["hand"] = hand.value
     item["type_"] = type_.value
     item["damage"] = (random.randint(minstat, maxstat)
                       if type_ != ItemType.Shield else 0)
     item["armor"] = (random.randint(minstat, maxstat)
                      if type_ == ItemType.Shield else 0)
     item["value"] = random.randint(minvalue, maxvalue)
     item["name"] = fn.weapon_name(type_.value)
     if hand == Hand.Both:
         item["damage"] = round(
             item["damage"] *
             2)  # both hands = higher damage, else they would be worse
         # The issue with multiplying by 2
         # is that everything will be even
         # so we have to force uneven ones
         if random.randint(1, 2) == 1:
             item["damage"] -= 1
     if insert:
         return await self.create_item(**item, conn=conn)
     return item
Beispiel #3
0
 async def create_random_item(
     self, minstat, maxstat, minvalue, maxvalue, owner, insert=True
 ):
     owner = owner.id if isinstance(owner, (discord.User, discord.Member)) else owner
     item = {}
     item["owner"] = owner
     type_ = random.choice(["Sword", "Shield"])
     item["type_"] = type_
     item["damage"] = random.randint(minstat, maxstat) if type_ == "Sword" else 0
     item["armor"] = random.randint(minstat, maxstat) if type_ == "Shield" else 0
     item["value"] = random.randint(minvalue, maxvalue)
     item["name"] = fn.weapon_name(type_)
     if insert:
         return await self.create_item(**item)
     return item
Beispiel #4
0
 async def create_random_item(self,
                              minstat,
                              maxstat,
                              minvalue,
                              maxvalue,
                              owner,
                              insert=True,
                              conn=None):
     owner = owner.id if isinstance(owner, (discord.User,
                                            discord.Member)) else owner
     item = {}
     item["owner"] = owner
     type_ = random.choice(self.config.item_types)
     if type_ in ["Scythe", "Bow", "Howlet"]:
         item["hand"] = "both"
     elif type_ in ["Spear", "Wand"]:
         item["hand"] = "right"
     elif type_ == "Shield":
         item["hand"] = "left"
     else:
         item["hand"] = "any"
     item["type_"] = type_
     item["damage"] = random.randint(minstat,
                                     maxstat) if type_ != "Shield" else 0
     item["armor"] = random.randint(minstat,
                                    maxstat) if type_ == "Shield" else 0
     item["value"] = random.randint(minvalue, maxvalue)
     item["name"] = fn.weapon_name(type_)
     if item["hand"] == "both":
         item["damage"] = round(
             item["damage"] *
             2)  # both hands = higher damage, else they would be worse
         # The issue with multiplying by 2
         # is that everything will be even
         # so we have to force uneven ones
         if random.randint(1, 2) == 1:
             item["damage"] -= 1
     if insert:
         return await self.create_item(**item, conn=conn)
     return item