Coder Social home page Coder Social logo

mrannouncerbot's People

Contributors

bsimser avatar code-ru-sh avatar influencer avatar legendairymoo avatar millermark avatar rorybecker avatar surlydev avatar wilbennett avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mrannouncerbot's Issues

Alternative image for day-night cycle

Hello there!
I watched the last stream and scribbled along the alternative non-licensed(aka free for use) version of the cog day-night cycle image. I saved it as a png but can reexport it into different layers or even make an svg-overhaul if needed. The picture is made in procreate and as such a psd is available too.
Should I create a pull request or is it ok as it is(it should be a transparent png, but i dunno if github actually messes with it)?
Best regards,
Oste

cogdaytime

IncludeIf

Mark,

Here is an example of what I was suggesting a few streams ago. To be clear, I'm not saying it's "better". Just the way I usually do it because "I" think it's easier to read and maintain. Let me know what you think.

Wil

Original:

static WeaponProperties GetWeaponProperties(WeaponDto weaponDto)
{
    WeaponProperties result = WeaponProperties.None;
    if (MathUtils.IsChecked(weaponDto.Ammo))
        result |= WeaponProperties.Ammunition;
    if (MathUtils.IsChecked(weaponDto.Finesse))
        result |= WeaponProperties.Finesse;
    if (MathUtils.IsChecked(weaponDto.Heavy))
        result |= WeaponProperties.Heavy;
    if (MathUtils.IsChecked(weaponDto.Light))
        result |= WeaponProperties.Light;
    if (MathUtils.IsChecked(weaponDto.Martial))
        result |= WeaponProperties.Martial;
    if (MathUtils.IsChecked(weaponDto.Melee))
        result |= WeaponProperties.Melee;
    if (MathUtils.IsChecked(weaponDto.Ranged))
        result |= WeaponProperties.Ranged;
    if (MathUtils.IsChecked(weaponDto.Reach))
        result |= WeaponProperties.Reach;
    if (MathUtils.IsChecked(weaponDto.Special))
        result |= WeaponProperties.Special;
    if (MathUtils.IsChecked(weaponDto.Thrown))
        result |= WeaponProperties.Thrown;
    if (MathUtils.IsChecked(weaponDto.TwoHanded))
        result |= WeaponProperties.TwoHanded;
    if (MathUtils.IsChecked(weaponDto.Versatile))
        result |= WeaponProperties.Versatile;

    return result;
}

Alternate:

static WeaponProperties GetWeaponProperties3(WeaponDto weaponDto)
{
    WeaponProperties result = WeaponProperties.None;
    IncludeIf(weaponDto.Ammo, WeaponProperties.Ammunition);
    IncludeIf(weaponDto.Finesse, WeaponProperties.Finesse);
    IncludeIf(weaponDto.Heavy, WeaponProperties.Heavy);
    IncludeIf(weaponDto.Light, WeaponProperties.Light);
    IncludeIf(weaponDto.Martial, WeaponProperties.Martial);
    IncludeIf(weaponDto.Melee, WeaponProperties.Melee);
    IncludeIf(weaponDto.Ranged, WeaponProperties.Ranged);
    IncludeIf(weaponDto.Reach, WeaponProperties.Reach);
    IncludeIf(weaponDto.Special, WeaponProperties.Special);
    IncludeIf(weaponDto.Thrown, WeaponProperties.Thrown);
    IncludeIf(weaponDto.TwoHanded, WeaponProperties.TwoHanded);
    IncludeIf(weaponDto.Versatile, WeaponProperties.Versatile);

    return result;

    void IncludeIf(string propertyValue, WeaponProperties value)
    {
        if (MathUtils.IsChecked(propertyValue)) result |= value;
    }
}

More Generic:

static WeaponProperties GetWeaponProperties(WeaponDto weaponDto)
{
    WeaponProperties result = WeaponProperties.None;
    IncludeIf(MathUtils.IsChecked(weaponDto.Ammo), WeaponProperties.Ammunition);
    IncludeIf(MathUtils.IsChecked(weaponDto.Finesse), WeaponProperties.Finesse);
    IncludeIf(MathUtils.IsChecked(weaponDto.Heavy), WeaponProperties.Heavy);
    IncludeIf(MathUtils.IsChecked(weaponDto.Light), WeaponProperties.Light);
    IncludeIf(MathUtils.IsChecked(weaponDto.Martial), WeaponProperties.Martial);
    IncludeIf(MathUtils.IsChecked(weaponDto.Melee), WeaponProperties.Melee);
    IncludeIf(MathUtils.IsChecked(weaponDto.Ranged), WeaponProperties.Ranged);
    IncludeIf(MathUtils.IsChecked(weaponDto.Reach), WeaponProperties.Reach);
    IncludeIf(MathUtils.IsChecked(weaponDto.Special), WeaponProperties.Special);
    IncludeIf(MathUtils.IsChecked(weaponDto.Thrown), WeaponProperties.Thrown);
    IncludeIf(MathUtils.IsChecked(weaponDto.TwoHanded), WeaponProperties.TwoHanded);
    IncludeIf(MathUtils.IsChecked(weaponDto.Versatile), WeaponProperties.Versatile);

    return result;

    void IncludeIf(bool cond, WeaponProperties value)
    {
        if (cond) result |= value;
    }
}

You could make the IncludeIf method global and generic as well. There would need to be a modification since you have to "change" the enum to a number to "or" it in a generic method. I don't think the global approach is worth the expense though (you have to box/unbox or something similar - like use IConvertible).

Bug in Emitter

There is a bug on line 113 of Emitter.ts... should be calling super.preUpdate() not super.update()..... sorry :(

LINQ

Mark,

Here is an example of what I was mentioning yesterday (HandleQuestionCommand event handler):

List<string> accessibleScenes = scenes
   .Where(m => m.Level <= userLevel)
   .Select(m =>
    {
       if (m.ChatShortcut.IndexOf(' ') >= 0)
           return $"\"{m.ChatShortcut}\"";
       else
           return m.ChatShortcut;
    })
   .ToList();

I'm not a big fan of putting blocks of code in LINQ. I think it obscures the code. LINQ is supposed to make code simple, readable and maintainable.

Here's an alternate version:

List<string> accessibleScenes = scenes
   .Where(m => m.Level <= userLevel)
   .Select(m => m.ChatShortcut.IndexOf(' ') >= 0 ? $"\"{m.ChatShortcut}\"" : m.ChatShortcut)
   .ToList();

Of course, you cannot always use the ternary and readability is still not the best. To do a general purpose solution, pull the block out into a function:

string QuotedIfSpace(string text)
{
    return text.IndexOf(' ') >= 0
       ? $"\"{text}\""
       : text;
}

Now you can do:

List<string> accessibleScenes = scenes
   .Where(m => m.Level <= userLevel)
   .Select(m => QuotedIfSpace(m.ChatShortcut))
   .ToList();

Or:

List<string> accessibleScenes = scenes
   .Where(m => m.Level <= userLevel)
   .Select(m => m.ChatShortcut)
   .Select(QuotedIfSpace)
   .ToList();

Your LINQ is much cleaner and you now have a utility function that you will probably find uses for elsewhere. If not, you can always make it a nested function in the current method.

Personally, I think all LINQ code should be like this. Single line per function call when using many and simple checks or method calls per function. Makes it really easy to see the flow and to rearrange, add, remove, comment out individual pieces, etc...

You like?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.