devolution

Author Topic: General Discussion  (Read 3821783 times)

0 Members and 26 Guests are viewing this topic.

Offline DarkTl

  • Hero Member
  • *****
  • Posts: 4737
Re: General Discussion
« Reply #8865 on: November 06, 2016, 09:30:52 AM »
I have the repo copy on my Android  :)
It doesn't work, but still is useful for coding far from larger devices.

Offline DarkTl

  • Hero Member
  • *****
  • Posts: 4737
Re: General Discussion
« Reply #8866 on: November 06, 2016, 10:29:48 AM »
It goes like
Code: [Select]
            for key in item.max:
                if "Left-Handed" in self.traits and item.slot == "smallweapon":
                    self.stats.max[key] += item.max[key]*2
                elif "Left-Handed" in self.traits and item.slot == "weapon":
                    self.stats.max[key] += int(item.max[key]*0.5)
                elif "Knightly Stance" in self.traits and key == "agility" and item.max[key] <0:
                    self.stats.max[key] += int(item.max[key]*0.5)
                elif "Sword Master" in self.traits and item.type == "sword":
                    self.stats.max[key] += int(item.max[key]*1.5)
                else:
                    self.stats.max[key] += item.max[key]
The easiest way to simplify it would be
Code: [Select]
if "Left-Handed" in self.traits and item.slot == "smallweapon":
    max_modifier*2
...
self.stats.max[key] += int(item.max[key]*max_modifier)
But it won't work for traits like Knightly Stance, since it should work only for agility [key], which we don't see outside of the "for" loop.

Offline Xela

  • Global Moderator
  • *****
  • Posts: 6893
  • "It's like hunting cows"
Re: General Discussion
« Reply #8867 on: November 06, 2016, 11:11:16 AM »
I can refactor it into shorter code or add new json fields but that looks legit.
« Last Edit: November 06, 2016, 01:45:09 PM by Xela »
Like what we're doing?

Offline DarkTl

  • Hero Member
  • *****
  • Posts: 4737
Re: General Discussion
« Reply #8868 on: November 07, 2016, 04:25:02 AM »
Well, if you think you can make the json filed flexible enough while not making the code 100 times more complex... I mean, it should understand what slot and what type of item it affects, which stats it affects, and in some cases understand if the stat change provided by item is positive or negative.
That would be one hell of a system  :D

Direct coding keeps logic clean, but also increases that amount of "ifs". It's still very readable, but I bet 6 "ifs" per trait is a blasphemy against pep8.
« Last Edit: November 07, 2016, 04:32:03 AM by DarkTl »

Offline Xela

  • Global Moderator
  • *****
  • Posts: 6893
  • "It's like hunting cows"
Re: General Discussion
« Reply #8869 on: November 07, 2016, 04:36:56 AM »
I'll take a look at it when I can, if forks are not anti pep8, it doesn't cover that but we might be able to restructure logic and make code better readable (and readability counts) :)
Like what we're doing?

Offline DarkTl

  • Hero Member
  • *****
  • Posts: 4737
Re: General Discussion
« Reply #8870 on: November 07, 2016, 07:02:55 AM »
I need a controllable effect.
Quote
"Regeneration": {"active": False, "desc": "Health restores every day.", "amount": 0}
This one will restore the amount of health per day.

I can set the amount in the code, like self.effects['Regeneration']['amount'] = 5, and it will work.
But I dunno how to take this amount from a json. When I write json field like
Code: [Select]
"effects": ["Regeneration"],I need to specify effect amount somehow.

Offline Xela

  • Global Moderator
  • *****
  • Posts: 6893
  • "It's like hunting cows"
Re: General Discussion
« Reply #8871 on: November 07, 2016, 07:16:39 AM »
Make 3 effects:

- Regen

- QuickRegen

- HealingFactor

:)

You can't really pass arguments through that fields without messing with code which loads them.
Like what we're doing?

Offline Xela

  • Global Moderator
  • *****
  • Posts: 6893
  • "It's like hunting cows"
Re: General Discussion
« Reply #8872 on: November 07, 2016, 09:23:33 AM »
I rewrote that code bit but your version was perfectly fine... and there isn't a better way to do it other than maybe pushing conditioning to JSONs. I am not really sure if that would result in better system.

There are some things you just need forks for... question is if pushing conditioning for those forks elsewhere in order to get rid of them is sensible or not.
Like what we're doing?

Offline DarkTl

  • Hero Member
  • *****
  • Posts: 4737
Re: General Discussion
« Reply #8873 on: November 07, 2016, 11:47:28 AM »
I rewrote that code bit but your version was perfectly fine... and there isn't a better way to do it other than maybe pushing conditioning to JSONs. I am not really sure if that would result in better system.
Ok, I restored the old code, since with the new one all items maxes just stopped working...

You can't really pass arguments through that fields without messing with code which loads them.
I hoped it's possible to trick the system somehow, like give it a list or a dict instead of string  :)

Offline Xela

  • Global Moderator
  • *****
  • Posts: 6893
  • "It's like hunting cows"
Re: General Discussion
« Reply #8874 on: November 07, 2016, 12:21:02 PM »

I hoped it's possible to trick the system somehow, like give it a list or a dict instead of string  :)

Sure, but we'd have to resolve that in loading code, it actually wouldn't be hard at all so if you need this, let do it.
Like what we're doing?

Offline DarkTl

  • Hero Member
  • *****
  • Posts: 4737
Re: General Discussion
« Reply #8875 on: November 07, 2016, 12:28:22 PM »
I thought maybe it would be easier to add a new trait field instead of rewriting effects code, like effect_power.

Offline Xela

  • Global Moderator
  • *****
  • Posts: 6893
  • "It's like hunting cows"
Re: General Discussion
« Reply #8876 on: November 07, 2016, 03:26:13 PM »
Prolly more difficult and more confusing...
Like what we're doing?

Offline picobyte

  • Jr. Member
  • **
  • Posts: 75
Re: General Discussion
« Reply #8877 on: November 08, 2016, 03:11:02 AM »
committed some json schema updates. should not interfere and probably not too interesting, although this file gives you an overview of most of the current concepts.

Offline DarkTl

  • Hero Member
  • *****
  • Posts: 4737
Re: General Discussion
« Reply #8878 on: November 08, 2016, 03:20:17 AM »
I don't really want to duplicate effects or rewrite them when it's possible to avoid it. I think I'll tie effect power to traits names. The effect will check character traits and calculate total regeneration.

committed some json schema updates. should not interfere and probably not too interesting, although this file gives you an overview of most of the current concepts.
I'm 100% sure that we don't have spells like "Fire 1", "Fire 2", "Fire 3" in the assets rpy. Those are remainings of very old version of BE in some old parts of the code like arena, which will be rewritten. All real, existing spells are only in be/assets.rpy.

Offline Xela

  • Global Moderator
  • *****
  • Posts: 6893
  • "It's like hunting cows"
Re: General Discussion
« Reply #8879 on: November 08, 2016, 03:46:37 AM »
If you say so. Effects are basically dicts so it would not be out of place to add a dict option to traits which activate them.
Like what we're doing?