Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
HWWand *wand = [[HWWand alloc] init];
HWMagic *magic = [HWSpell genericSpell];
[wand setMagic:(__bridge HWSpell *)magic];
Copy link

chrisgibbs commented Jan 25, 2013

HWStudent *ron = [[HWStudent alloc] init];
[ron equipWand:wand];
[ron beginLearning:(__bridge HWWandSpell *)magic];

[ron castSpell:(__bridge HWWandSpell *)magic];

Copy link

larsacus commented Jan 25, 2013

Shouldn't Ron simply setMagic:? The cast is implicit.

Copy link

cnstoll commented Jan 25, 2013

- (BOOL)equipWand:(HWWand *)wand; // The wand chooses the wizard.

Copy link

jab2109 commented Jan 25, 2013

UIWaveGestureRecognizer *waveRecognizer = 
    [[UIWaveGestureRecognizer alloc] initWithTarget:wizardWorld action:@selector:(vanquishEvil)];
[wand addGestureRecognizer:waveRecognizer];

Copy link

cnstoll commented Jan 25, 2013

HWWandSpell *harrySpell = [HWWandSpell expelliarmus];
HWWandSpell *voldemortSpell = [HWWandSpell avadaKedavra];

HWSpellComparisonResult spellResult = [harrySpell evaluateSpellVersusSpell:voldemortSpell withSpellComparator:(^HWSpellComparator)(id spell1, id spell2) ^{
if ([spell1.wizard.wand == nil])
    return HWSpellResultLose;
if ([spell1.wizard isKindOfClass:[[HWCreature houseElf] class]])
    return HWSpellResultWin;
if ([spell1.wizard containsSoulFragmentOfWizard:spell2.wizard]) 
    return HWSpellResultWin;
if ([spell2.wizard.power > spell1.wizard.power])
    return HWSpellResultLose;

return HWSpellResultDraw;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment