« first day (205 days earlier)      last day (3375 days later) » 

1:24 AM
0
Q: Calculate distance using speed of sound

PhrancisBeen working on learning Java and this was a challenge as part of a chapter on data types. Create a program that computes how far away, in feet, a listener is from a sound. Sound travels approximately 1,100 feet per second through air. You can also compute the distance to a large ob...

@SimonAndréForsberg What do you think? ^^
 
 
9 hours later…
10:55 AM
I think the current answers you got has said most.
but I did find one thing to add
 
 
2 hours later…
12:49 PM
hey
 
strange that the convention in java for booleans is to not have isWhatever
hey @skiwi
 
@bazola huh?
hey @bazola
 
1
A: Calculate distance using speed of sound

Simon André ForsbergJust one thing: Do not have a boolean field that begins with is. Like this one: public boolean isEcho; (200_success and others is right that this should not be public) In Java, the naming conventions for boolean getters are that they should begin with is, followed by the name of the variable...

 
I'd say it's fine
If you have a field isEcho then it would be silly to make the getter isIsEcho
 
in objective-c, the convention is to say isWhatever or hasWhatever or even didSomethingHappen
 
12:53 PM
@skiwi if you have a field isEcho and have a getter isEcho then you are not following the naming conventions.
 
brb
 
the boolean field should not be prefixed with 'is'
 
I tend to disagree as echo by itself doesn't really mean anything
boolean started, stopped, waiting; etc. all mean something obvious
not sure how to explain that best ^
Does anyone have a suggestion on how to represent Taunt/Stealth/Windfury/"Sleep" data in my 'GUI'?
I would ideally have it that it always uses the same amount of lines
 
@skiwi String.join(stuff, ", ")
 
Is it really the best?
I was first thinking on having taunted names be bold, stealth be italic, etc.
but I kinda run out of options there
 
1:03 PM
why not use a single letter?
T for taunt, S for stealth, W for windfury and Z for sleep
 
Afraid it would get a bit cryptic then
biggest issue is just that my GUI sucks :)
 
@skiwi Who cares about the best? You just want a way to show it, right?
I mean... this wasn't really intended to be a pretty GUI?
 
It would be my final GUI if it were good enough
 
Like me!
 
> I want to be the very best
Like no one ever was
To catch them is my real test
To train them is my cause
 
1:07 PM
using bold and italic to represent taunt and stealth is a bad way to represent things. Using a single letter is way too confusing.
either add some graphical symbols, or use the full names, IMO.
 
I'll try if I can fit the stuff on one line
There's quite some more than I initially considered
 
@skiwi pokemon?
 
@bazola Someone noticed :)
 
@skiwi or you can always let the abilities take up two lines.
 
when I did the search I figured it was going to be heavy metal or something
 
1:10 PM
or even x lines.
 
@bazola That sheds a whole new light on how I would read it, lol
 
I also thought "Pokémon", even though I haven't seen much of it.
 
@skiwi does your GUI render cards on the screen yet? I would think that if you just render cards on the screen, then you have lots of options for stealth and taunt. You could fade the alpha for stealth, for example
 
LOL
@bazola Not rendering on the screen, that's still quite a way off
 
@skiwi you do show some info about the cards on the screen though, don't you?
 
1:12 PM
half a days work in JavaFX could get it done i think
since you don't have to interact with any of the cards, just show them
 
@SimonAndréForsberg very basic info
 
@Phrancis please stop doing this!
class SoundSpeedCalc {
    public static void main(String args[]) {
 
@skiwi but still, you do show stuff.
 
Hmm, I haven't found the stealth tag yet
ATK, HEALTH, CONTROLLER, ENTITY_ID, COST, CREATOR, ZONE_POSITION, CANT_PLAY, BATTLECRY,
PREMIUM, DEATHRATTLE, TAUNT, DIVINE_SHIELD, CHARGE, TRIGGER_VISUAL, FORGETFUL, EXHAUSTED,
AURA, SPELLPOWER;
Then I'll live without stealth for a couple of commits
 
strange
 
1:16 PM
Same for windfury I think
I've only parsed one logfile so far, and I get a sysout if it detects some property it doesn't know
 
maybe they are just AURAs with only one possible target
 
@bazola That would be way too complex for HS ;)
 
@bazola what's wrong with doing that?
 
@SimonAndréForsberg putting the main call inside the class seems to violate OOP?
I would expect that all main would do is create an object for the calculator and then pass in whatever test values and log the results
 
Let's see how many bugs this change will create
 
1:19 PM
@bazola in Java, you have to put the main method inside a class. And I believe @Phrancis has one SoundSpeed and one SoundSpeedCalc
 
well I certainly can't argue with you :) you have just a tiny bit more experience with java than me. I guess I am spoiled because the main call is usually abstracted away from the code that I am writing in a Launcher class or something
 
I still like HearthMonitor GUI, I just hoped it to be somewhat more awesome
Now I need to figure out how to make it more awesome
Hardcoding stuff is ugly
I shouldn't commit as-is
 
@bazola the SoundSpeedCalc is @Phrancis' "Launcher class". Although I would name it SoundSpeedMain, and make it a public class
 
yeah I think you are right that I am really just complaining about the name of it
@SimonAndréForsberg is this the correct .gitignore for cardshifter?
*.class
.settings/
.metadata/
*/bin/**
*/target/**
dependency-reduced-pom.xml
pom.xml.versionsBackup
.classpath
.project
/target/

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.ear

# virtual machine crash logs, see java.com/en/download/help/error_hotspot.xml
hs_err_pid*

### Ignore Netbeans workspace
nb-configuration.xml
nbactions.xml

### Intellij ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm
*.iml

## Directory-based project format:
 
@bazola there's another .gitignore inside the gdx directory, which is used for ignoring some more LibGDX stuff
 
1:34 PM
cool, looked like i was missing something
 
if you want a gitignore for your libgdx project, the one in the gdx directory is the one you are looking for
 
> Added basic GUI.
 
Initially I was thinking about first implementing all commands
Perhaps it's better though to first make sure I can see the card names
 
[skiwi2/HearthMonitor] build #20 for commit 770e15a5 on branch develop passed
 
I still want to make some sort of text-based MMORPG as an app
though I want to make it complicated and easy at the same time
Idea comes from a MMORPG that I have played for quite a long time ending a few years ago, where you could "auto attack" and if you were good enough that would do the job, or you could be active and you would get the kill way quicker, but had to be actually active
 
1:49 PM
text based huh? so like you type West and your character goes west and you get a description of what you are seeing?
 
@bazola Not that much text-based, still normal interface
but not full 3D GUI
How to put it, regular interface, but no graphics (or barely)
 
so like this?
 
gotta do some stuff, can only check later :(
I think the idea of making an MMORPG backend is very cool
and also having people actually play a game I made
 
yeah
 
I've had that before with a text-based browser MMORPG, but those days are gone
Was like 30 players online at same time, and 100 unique a day, and generating money
 
1:54 PM
people actually played your text based game?
 
2:09 PM
@bazola yep :)
 
thats really cool
 
2:28 PM
@skiwi why did it die?
 
@SimonAndréForsberg The general concept died because smartphones started to come and everyone wanted fancy graphics, at least that is what I think
My game is a bit more complicated... It wasn't mine at the beginning, worked for someone else, ultimately got the game but didn't make enough content or not at all anymore at some point
I must say that it was a gangster/mafia-themed game, never found it fun to play and there was no logical gameplay in it xd
 
@skiwi so people just stopped playing?
 
@SimonAndréForsberg Yea, at least that's what I think
 
2:43 PM
Monking
 
monking @Phrancis
 
Man, so many good reviews, if I just keep writing Java questions I'll be at 10K rep learn so much so quickly! ;)
3
Still having a bit of difficulty visualizing the constructor concept, but I think if I study 200's answer it will help me
 
3:07 PM
yeah 200s answer was really good i thought
 
> This one may sound less original, but I talked to @MGS1GreyFox and we think this may be a good idea. I think we could have a mod which features a few "standard" cards games, like Poker, Blackjack, Spades, etc. My thought is that it would allow for several interesting game mechanics to be implement, with very little game balance work and low maintenance. Example: - Common draw pile - "Dealer" concept (like in Blackjack) - Combinations of variable number of cards (like in Poker) - Variations...
of UI, for example the Poker Texas Hold'em with shared cards on the table, some face up and some face down, etc. It would also provide a simple way for a new player to try the Cardshifter platform without having to learn a bunch of unfamiliar game rules.
 
I'm still trying to figure out how to develop software without being annoyed by all the little things
 
> That means that you have to find plausible objects to model — the more realistic, the better. What's a SoundSpeedCalc? I don't know; you can't buy one. But you can sure buy a sonar!
^^ This made be literally LOL
 
As example, I've got an XML file with all HS data in it, trying to figure out where to put it, eyt at the same time I don't want to bea nnoyed with that kind of stuff
 
3:27 PM
<meeting>
 
@skiwi You want things simple, but complicated? How would that work?
 
By not making that many typos
I don't know though
Trying to find some fun in programming, but it's difficult
 
Really? I find fun in many places!
 
I'm trying to think about how to stop thinking about things
Years ago I would get awesome idea to make some browser game and start right away
now I try to be realistic and see that it's not going to end up anywhere anyway
 
3:57 PM
so this approach looks pretty clean? even if I add two or three more properties to the enum?
	public enum BuildingType {
	    BANK(Color.GREEN, 1000),
	    FARM(Color.OLIVE, 400);

	    private final Color color;
	    private final int storageCapacity;

	    private BuildingType(Color color, int storageCapacity) {
	        this.color = color;
	        this.storageCapacity = storageCapacity;
	    }

	    public Color getColor() {
	        return this.color;
	    }

	    public int getStorageCapacity() {
	    	return this.storageCapacity;
	    }
	}
 
@bazola Consider BuildingTypeData perhaps
However for now this looks fine
 
so it is common in java to use enums as a kind of plain old data inner class?
 
Usually yes I think, and add some common methods if you feel like having them, or have it implement an interface
 
thats pretty interesting
i suppose it combines the ideas of a C style enum where it is simply an integer with a name, and the idea of class properties, into one concept
 
@bazola sorta
I wish Java would allow for some kind of non-static typing sometimes :/
 
4:07 PM
</meeting>
 
Have a JSON object here and really do not feel like manually iterating or whatever, I just want the darn key :D
Need to look into the easiest tool
 
@skiwi what would you use it for?
 
@bazola To get a JSON value easily, I know exactly where I want to find it
Except that it seems that I need to iterate as the JSON filed oesn't map any thing :/
 
objective-c has ways to convert JSON to a dictionary
 
This will be pretty awesome if I can manage to get it to work
 
4:19 PM
this still looks okay?:
	public enum BuildingType {
	    BANK(1000, ResourceType.GOLD, 0),
	    FARM(400, ResourceType.GREENGRASS, 1),
	    MINE(400, ResourceType.ROCKS, 1),
	    FURNACE(400, ResourceType.METAL, 1),
	    HOUSE(400, ResourceType.SLAVES, 1),
	    RECRUITER(400, ResourceType.ARMIES, 1),
	    WIND_MACHINE(800, ResourceType.ENERGY, 1),
	    TRADE_HUT(1000, null, 0),
	    FORT(0, null, 0),
	    CASTLE(0, null, 0);

	    private final int storageCapacity;
	    private final ResourceType resourceProduced;
	    private final int amountResourceProduced;
 
still looks okay to me
 
then i would just have to check if it was a couple of special cases of BuildingType to run special logic for those
 
@bazola I don't think that's a good idea
You ideally don't want special case checks in your code, or special logic
 
you are suggesting polymorphism?
 
I don't know what your issue is ;)
 
4:26 PM
run different logic but only for 3 out of the 10 types of buildngs
like building.update() will just add the amount produced to the building, but if it is a bank, it will calculate interest based on the amount stored and add that instead
 
So I would add an update() method to the enum, and implement it as needed
 
hmm
but i would still be checking the type in that method?
also there would then be tight coupling between the enum and the class using it
 
hmm
Ah right
maybe use a simpler approach and refactor later
 
this is what it looks like right now
	public void updateResources() {
		if (this.getAvailableStorage() > 0) {
			if (this.type == Type.BANK) {

			} else {
				this.occupiedStorage = MAX(this.occupiedStorage + this.type.getAmountResourceProduced(), this.type.getStorageCapacity());
			}
		}
	}
although i actually want MIN
 
Hmm, it could be done so much nicer
but you're stuck on < Java 8, right?
 
4:42 PM
pretty much I think
 
4:57 PM
@skiwi this enum approach seems to lead to needing duplicate getters if I want full encapsulation and private instance variables
i need this method in the class now:
public ResourceType getResourceType() {
    return this.type.getResourceProduced();
}
 
can't really tell much withotu seeing all code there
 
public class Building {

    public enum Type {
        FARM(400, ResourceType.GREENGRASS, 1),
        MINE(400, ResourceType.ROCKS, 1),
        FURNACE(400, ResourceType.METAL, 1),
        HOUSE(400, ResourceType.SLAVES, 1),
        RECRUITER(400, ResourceType.ARMIES, 1),
        WIND_MACHINE(800, ResourceType.ENERGY, 1),
        BANK(1000, ResourceType.GOLD, 0),
        TRADE_HUT(1000, null, 0),
        FORT(0, null, 0),
        CASTLE(0, null, 0);

        private final int storageCapacity;
        private final ResourceType resourceProduced;
 
5:45 PM
Sorry @bazola, I cannot really get a clear picture of it
what's wrong with the duplicate getters?
 
nothing i guess
 
6:10 PM
I made some evil code today :)
 
> Added ability to load card data from JSON files containing card data.
 
@SimonAndréForsberg Why does the ECS system not have a way store objects rather than components, is that something inheritly to the system?
It leads to some redundant redundancy imo
I don't have an alternative at hand though :)
 
[skiwi2/HearthMonitor] build #21 for commit 12236f41 on branch develop passed
 
Aw yiss!
 
> Added the card name to the GUI.
 
6:21 PM
@skiwi That is pretty darn nice!
 
Going from "???" to the names is quite some improvement!
 
Indeed!
 
[skiwi2/HearthMonitor] build #22 for commit 9b740dff on branch develop passed
 
 
> Added hero class to the GUI.
 
6:27 PM
I believe I need to implement some more events there ;)
Want to see what black magic I've used?
/**
 * Created by Frank van Heeswijk on 23-2-2015.
 */

var CardData = Java.type("com.github.skiwi2.hearthmonitor.CardData");
var Optional = Java.type("java.util.Optional");
var setList;
var allSets;

function setSetList(setListRaw) {
    setList = JSON.parse(setListRaw);
}

function setAllSets(allSetsRaw) {
    allSets = JSON.parse(allSetsRaw);
}

function getCardData(cardId) {
    for (var i = 0; i < setList.length; i++) {
        var set = setList[i];
        for (var j = 0; j < allSets[set].length; j++) {
 
[skiwi2/HearthMonitor] build #23 for commit 851665b5 on branch develop passed
 
1
Q: Parsing log files of HearthStone: Loading card data without external libraries for JSON

skiwiI'm still working on a parser that can parse log entries from a game called HearthStone, the overall idea is that it will read the log file live when the game is running, parses the log file and show interesting and useful data in real time. The focus for this question is to load the card data f...

Instantiating Java objects from within Javascript ftw!
 
6:48 PM
pretty neat
 
Don't know if it's pretty neat or uber big hack though ;)
 
7:08 PM
My eyes still are a bit irritated :/
Had to have eye drops this morning for a checkup
 
7:22 PM
> This might interfere with the message splitting. The regex is definitely not sophisticated enough to handle this
 
8:08 PM
Yay! Names are now displayed if a card enters another zone
 
> Card data gets updated when an entity changes zone.
 
@bazola what getters are duplicate?
@bazola I would create an abstract class Building and then some subclasses, ResourceBuilding (for all buildings that create resources), and one subclass for each "special" building.
@skiwi uber big hack IMO.
 
@SimonAndréForsberg but it works!
 
[skiwi2/HearthMonitor] build #24 for commit d6ceaaf5 on branch develop passed
 
@skiwi I surely hope it does, otherwise you shouldn't be asking a question about it on Code Review.
 
8:14 PM
@SimonAndréForsberg ;)
Though the concept of Javascript inside Java is still ainteresting to me
 
@skiwi What kind of objects is it that you want to store within the ECS?
 
@SimonAndréForsberg I wanted to store a CardData object with an entity
The 1:1 mapping is correct, but I think CardDataComponent is a bit cumbersome
 
@skiwi and what does a CardData object contain?
 
@SimonAndréForsberg all kinds of data, currently..
public class CardData {
    private static final CardDataLoader CARD_DATA_LOADER = new CardDataLoader();

    private final String id;
    private final String name;
    private final Optional<String> playerClass;
 
then it's not really made for an ECS.
 
8:19 PM
btw, I am mostly surprised about The fact that undefined translates to Optional.empty()
@SimonAndréForsberg How come?
 
@skiwi the whole point of ECS is to seperate the object into different components, your CardData is basically "this contains everything!!!"
 
Hmm, ok
 
I think CardDataComponent is the way to go there.
or HearthMonitorComponent
or something
 
even though it isn't really made for ECS, you say?
 
well, if it only contains id, name and playerClass, then a component would work.
but if it contains "all kinds of data", then it doesn't really fit well with an ECS.
I have no plans to add a setUserObject for the Entity class.
 
9:01 PM
ok ^^
 
 
2 hours later…
10:31 PM
> Update story-prelude.html

Added Prelude story chapter.
> Update story-invasion.html

Added Invasion story chapter.
 
10:52 PM
@skiwi You're the one that added the attributes to the ECS, all three of your CardData are Strings, why not make an ECSAttribute for each of them?
 
> Update story-corruption.html

Added Corruption story chapter.
 
@SimonAndréForsberg i have this in both the enum and the class
    public ResourceType getResourceProduced() {
        return this.resourceProduced;
    }
 
@bazola that's probably possible to solve. First of all, are you actually using both getters in your code? (Do you call them?)
@skiwi What do you mean by "creating objects to store all properties of some item down a JSON object" ?
 
yeah it will end up being used
 
Then use it :)
I think it makes sense that it exists in both the enum and the class
 
11:01 PM
> Update story-enter.html

Added Enter Cyborg Chronicles story chapter.
 
11:59 PM
RELOAD!
[Cardshifter/Cardshifter] 1 issue comment.
 

« first day (205 days earlier)      last day (3375 days later) »