Skip to content

Commit

Permalink
I think power = 0 works now!?
Browse files Browse the repository at this point in the history
  • Loading branch information
DigiDuncan committed Nov 27, 2023
1 parent 1475e15 commit c103f6a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
4 changes: 2 additions & 2 deletions sizebot/cogs/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ async def objectcompare(self, ctx, *, args: str):
Used to see how an object would look at your scale.
Examples:
`&objectcompare lego`
`&objcompare moon as @Kelly`
`&objcompare moon to @Kelly`
"""

argslist = args.rsplit(" as ", 1)
argslist = args.rsplit(" to ", 1)
if len(argslist) == 1:
what = argslist[0]
who = None
Expand Down
2 changes: 1 addition & 1 deletion sizebot/lib/macrovision.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ async def get_url(people, *, shorten = False):
if len(people) <= 0:
raise ValueError("At least one person is required")

people.sort(key=itemgetter("height"), reverse=True)
people.sort(key=itemgetter("height.value"), reverse=True)

world_height = people[0]["height"]

Expand Down
17 changes: 16 additions & 1 deletion sizebot/lib/proportions.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,13 @@ def scaled(self) -> StatBox:
# TODO: THIS DOES NOT WORK.
# .as_dict() is for the base user, so when it goes to do the calculations, it's not using the new one.
# This only affects equations with power = 0.
return StatBox(self.user, [s.scale(self.user.stats["scale"], self.as_dict) for s in self.stats])
scaled_stat_box = self.partial_scaled_dict
new_stats = []
for s in self.stats:
ns = s.scale(self.user.stats["scale"], scaled_stat_box)
scaled_stat_box[ns.stat.sets] = ns.value
new_stats.append(ns)
return StatBox(self.user, new_stats)

def get(self, stat_name: str) -> StatValue | None:
g = (s for s in self.stats if s.stat.sets == stat_name)
Expand All @@ -185,6 +191,15 @@ def get(self, stat_name: str) -> StatValue | None:
@property
def as_dict(self) -> dict:
return {s.stat.sets: s.value for s in self.stats if s.value is not None}

@property
def partial_scaled_dict(self) -> dict:
known_stats = {}
for s in self.stats:
if s.value is not None and s.stat.power is not None:
new_stat = s.scale(self.user.stats["scale"], known_stats)
known_stats[new_stat.stat.sets] = new_stat.value
return known_stats



Expand Down

0 comments on commit c103f6a

Please sign in to comment.