millermark / mrannouncerbot Goto Github PK
View Code? Open in Web Editor NEWA Twitch bot written in C#
A Twitch bot written in C#
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
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).
Hi Mark,
Here is a link to the overview page for the NPM package I mentioned in todays stream that gives you LINQ and other c# / .net framework concepts in TS.
For an overview see https://www.npmjs.com/package/typescript-dotnet
I have only ever used it with a module loader in Angular projects bt from what i can see you can install the es6 version of the library using:
npm install typescript-dotnet-es6
There is a bug on line 113 of Emitter.ts... should be calling super.preUpdate() not super.update()..... sorry :(
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?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.