ScalaQuest: The Scala Adventure
1
Ale jandro Lujan
1
S c al a Qu e st: T h e S ca l a A dv e nt u re 1 A le jand r o L - - PowerPoint PPT Presentation
S c al a Qu e st: T h e S ca l a A dv e nt u re 1 A le jand r o L ujan 1 W h o? D a vi d , C h ri s ti a n, E d ua r do, M a ur i ci o 2 W h y d o y ou c a re? 4 Y ou wa n t to l evel up yo u r S cala 4 Y ou wa n t to gr o w yo u r t eam 4 Y ou
Ale jandro Lujan
1
David, Christian, Eduardo, Mauricio
2
4 You want to level up your Scala 4 You want to grow your team 4 You want to encourage others 4 You want to have fun
3
4 I've been teaching Scala for 5+ years 4 I've been teaching since high school 4 I learned english by playing a game
4
5
6
Albert Einstein on the Zelda series
7
4 Jane McGonigal 4 Tom Baranowski 4 Learning Games Network 4 MIT Game Lab 4 International Journal of Serious Games
8
1
Mihaly Csikszentmihalyi, Flow (1990)
9
10
11
Juan Ex
4 DataLand 4 Farmers harvest manually
12
Computers
4 A while back, computers appeared
13
Computers
4 A while back, computers appeared 4 Powerful forces arose 4 4-train
14
Computers
4 A while back, computers appeared 4 Powerful forces arose 4 4-train, Sea-cross-cross
15
Computers
4 A while back, computers appeared 4 Powerful forces arose 4 4-train, C-cross-cross, Hava 4 Data harvesting more effjcient
16
Computers
4 A while back, computers appeared 4 Powerful forces arose 4 4-train, C-cross-cross, Hava 4 Data harvesting more effjcient 4 For a time, it was good
17
Computers
4 A while back, computers appeared 4 Powerful forces arose 4 4-train, C-cross-cross, Hava 4 Data harvesting more effjcient 4 For a time, it was good 4 Then, the Complexity Plagues appeared
18
Ski
4 Roamed DataLand for long 4 Tamed many forces 4 Discovered a powerful one 4 Named it Scala 4 Wanted this great power to be wielded wisely 4 Gathering order of apprentices 4 Order of the Ski 4 Order[Ski] for short
19
20
4 Successful Kickstarter 4 Three levels ready 4 Level 4 on the way 4 Launching in a few weeks
21
4 Phaser.js frontend 4 Play and Scala backend 4 Micro-challenges evaluated on the client side 4 Final challenges compiled and tested on the backend
22
23
24
4 Map size and tiles 4 Items: location, sprites 4 Animations 4 Sounds
25
26
27
Image("goblinAvatar", "goblin_avatar.png", 124, 124) Sound("ambient_02", "ambient_02.ogg") Animation("left", (11 to 21).reverse, 8) smallGoblin = NPC("small-goblin", power = 5) smallGoblin.withRandomHP(min, max) val sprites = Sprites(player, npcs, items, prizes, exit, statics)
28
4 Serialized to JSON 4 Frontend had minimal changes 4 Unit tested 4 Reduced duplication drastically 4 Caught dozens of bugs 4 Refactoring is painless
29
4 (there is no bad)
30
4 Event Sourcing 4 Akka persistence 4 One persistent actor per user 4 DynamoDB 4 Careful about model evolution
31
// This function is applied to all incoming commands while the actor is running val receiveCommand: Receive = { case command: String => EventParser.parse(command) match { case event: GameEvent => persist(event)(updateState) case invalidCommand => log.debug(s"Command was not a valid event: $command") } }
32
def updateState(event: GameEvent): Unit = { log.debug(s"Updating state with event '$event'") event match { case LevelFinished(ts, levelId) => levelState = LevelState.startLevel(levelId + 1) case MainChallengeSuccess(ts, levelId) => levelState = levelState.copy(mainChallengeCompleted = true) // An item that is collected goes to the inventory by default case ItemCollected(ts, levelId, itemKey) => levelState = levelState.copy( collectedItems = levelState.collectedItems + itemKey, inventory = levelState.inventory + itemKey ) ... } }
33
34
4 Inexpensive 4 Scalable 4 Secure 4 Easy-ish to use
35
36
37
4 Can run any JVM app 4 Including one that packs a compiler 4 Very restricted 4 Priced for elasticity
38
4 Packaging the app 4 Tuning resources 4 Warmup time
39
Scala app + instructions on how to publish to Amazon Lambda: https://github.com/mvinesn/aws-lambda-example- scala
40
41