Author Topic: Programming Megathread  (Read 144187 times)

made videos resizable on my bl embedder script last night

https://gfycat.com/MenacingTenderAndeancondor

it was a big pain in the ass
nice

hey does anybody have experience with jquery in these parts of this town let me know

I've used jQuery a moderate amount


Code: [Select]
using System;
using System.Collections.Generic;

namespace TurnBasedTest
{
public class Weapon : Item
{

public enum WeaponTypes { Sword, Axe, Spear, Bow, Crossbow, Wand, Staff, Gauntlet };

public WeaponTypes weaponType;

public int damage;

public Weapon(string _name, int _value, int _damage, WeaponTypes _weaponType) : base(_name, _value, _itemType:ItemTypes.Weapon)
{
damage = _damage;
itemType = ItemTypes.Weapon;
weaponType = _weaponType;
}

public void Display()
{
Console.WriteLine("Weapon Type: " + weaponType);
Console.WriteLine("Damage:  " + damage);
}




}


}

so lets say i have a Weapon Class that is inherited from the Item class. right now I have an enumerator for weapon types but should i split them all up into seperate classes that inheret from Weapon? They don't do any other damage calculations, so im guessing no. Also, I have a WeaponTypes weaponType to keep track of the individual weapon type when it's created, but this naming is confusing, what can I do to remedy it? I obviously don't want WeaponTypes weaponType.


oh btw this is c#
« Last Edit: July 03, 2017, 01:35:56 PM by Waru »

hey does anybody have experience with jquery in these parts of this town let me know

I do but haven't used it in several years so my knowledge is outdated.

Well first I'd recommend making that enum static.

Second, the answer to your question depends on how different those weapon types are. If there are a lot of differences between the functionality of the weapon types, then it would be a good idea to take advantage of inheritance/polymorphism and make them their own classes.

So, can anybody describe the pros and cons of Kotlin vs Java, because what the forget is this:
Code: [Select]
package hello
fun main(args: Array<String>) {
   println("Hello World!")
}
I've been seeing it everywhere, it's even supported by android studio and eclipse, and apparently it was a real big deal when it was announced for android studio at I/o this year. Should I take a look at it or stick with good ol' Java?


make an abstract class for each weapon type and have each weapon implementation inherit from one of those classes

So, can anybody describe the pros and cons of Kotlin vs Java, because what the forget is this:
Code: [Select]
package hello
fun main(args: Array<String>) {
   println("Hello World!")
}
I've been seeing it everywhere, it's even supported by android studio and eclipse, and apparently it was a real big deal when it was announced for android studio at I/o this year. Should I take a look at it or stick with good ol' Java?
I'd stick with what's well known, reliable and extensively supported
« Last Edit: July 03, 2017, 06:12:33 PM by AndroFox »

make an abstract class for each weapon type and have each weapon implementation inherit from one of those classes

what benefits does this have tho and why is this better than the other solutions?

what benefits does this have tho and why is this better than the other solutions?
makes it easier to maintain and if you want to roll out a change to all weapons you can just change the template and it'll update for all

So, can anybody describe the pros and cons of Kotlin vs Java
it's literally just syntax. if you like kotlin's syntax more than java's, use kotlin. otherwise, use java. they're both on the JVM so they are completely interoperable and functionally identical, just like with any JVM language

apparently kotlin can also be compiled to binary if you're interested in that but as far as I can tell it's a bit of a work in progress so
there's ALSO an officially-supported javascript transpiler but imo transpiling to js is kinda gay, except for typescript which gets a pass since it's just a superset of js. and also I'm sure there's at least a few java to js transpilers

kotlin sounds swedish

makes it easier to maintain and if you want to roll out a change to all weapons you can just change the template and it'll update for all

but I already have a weapon class that I can change?

Imo I'd have one class for everything as long as they all have the same basic behavior.

As soon as they start having different behavior (e.g. if weapontype = x then do a, if weapontype = y then do b, etc)

I recently discovered a way to modify the byte code of functions at runtime in UnrealScript. I've partially released a proof of concept here.

This works by abusing the fact that class members in UnrealScript are actually just objects that hold metadata. You can get a reference to these metadata objects by using FindObject, DynamicLoadObject or the AllObjects Iterator.

Normally the class of these metadata objects are not exposed to unrealscript, so it's not possible to make changes to them. To work around this, I created a stub for each type of metadata -- and using a modified compiler -- allowed myself to forcefully cast them into their respective stub.



but I already have a weapon class that I can change?

Yeah only do that if you're going add weapon specific calculations, otherwise you're going to end up with a switch statement to branch off into different methods and that can get pretty hairy if you've got a lot of weapon types.
« Last Edit: July 04, 2017, 03:03:40 AM by SUSHI »