Skip to content

Instantly share code, notes, and snippets.

@larsacus
Last active December 11, 2015 17:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save larsacus/4636213 to your computer and use it in GitHub Desktop.
Save larsacus/4636213 to your computer and use it in GitHub Desktop.
Objective-Potter
HWWand *wand = [[HWWand alloc] init];
HWMagic *magic = [HWSpell genericSpell];
[wand setMagic:(__bridge HWSpell *)magic];
@chrisgibbs
Copy link

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

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

@larsacus
Copy link
Author

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

@cnstoll
Copy link

cnstoll commented Jan 25, 2013

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

@josh-berlin
Copy link

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

@cnstoll
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