From 0c495cee91cdeaf792551db242ed95e9bca110a4 Mon Sep 17 00:00:00 2001 From: Jon P Date: Sun, 23 Apr 2023 12:58:50 +0100 Subject: [PATCH 1/4] planning in excalidraw. ScoreCard and Frame class design done. Need to check design/methods work before designing controller models --- mind_map.excalidraw | 1377 +++++++++++++++++++++++++++++++++++++++++++ models.rb | 0 2 files changed, 1377 insertions(+) create mode 100644 mind_map.excalidraw create mode 100644 models.rb diff --git a/mind_map.excalidraw b/mind_map.excalidraw new file mode 100644 index 00000000..532c8bd8 --- /dev/null +++ b/mind_map.excalidraw @@ -0,0 +1,1377 @@ +{ + "type": "excalidraw", + "version": 2, + "source": "https://excalidraw.com", + "elements": [ + { + "type": "rectangle", + "version": 1255, + "versionNonce": 405334431, + "isDeleted": false, + "id": "Br-XRAEs2P0LbQeJ2Euww", + "fillStyle": "hachure", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 737.1492780501035, + "y": 253.99197319197958, + "strokeColor": "#000000", + "backgroundColor": "transparent", + "width": 252.57138061523438, + "height": 435.44940874009325, + "seed": 1372924327, + "groupIds": [], + "roundness": { + "type": 3 + }, + "boundElements": [ + { + "id": "HHLbJVJz_OMr232-JBPf1", + "type": "arrow" + }, + { + "id": "jX8kezK-o62a31VQkw-qd", + "type": "arrow" + } + ], + "updated": 1682249459599, + "link": null, + "locked": false + }, + { + "type": "arrow", + "version": 4643, + "versionNonce": 397958591, + "isDeleted": false, + "id": "HHLbJVJz_OMr232-JBPf1", + "fillStyle": "hachure", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 1002.8635419661191, + "y": 428.9375011927595, + "strokeColor": "#000000", + "backgroundColor": "transparent", + "width": 226.88974973454606, + "height": 0.4700975409245416, + "seed": 1105884999, + "groupIds": [], + "roundness": { + "type": 2 + }, + "boundElements": [], + "updated": 1682249459599, + "link": null, + "locked": false, + "startBinding": { + "elementId": "Br-XRAEs2P0LbQeJ2Euww", + "gap": 13.14288330078125, + "focus": -0.19453149030723224 + }, + "endBinding": { + "elementId": "lWbVyPY6tn5hjSfnoJP-m", + "gap": 21.571426391602017, + "focus": 0.15632314656123583 + }, + "lastCommittedPoint": null, + "startArrowhead": null, + "endArrowhead": "arrow", + "points": [ + [ + 0, + 0 + ], + [ + 226.88974973454606, + -0.4700975409245416 + ] + ] + }, + { + "type": "rectangle", + "version": 1613, + "versionNonce": 1610323633, + "isDeleted": false, + "id": "lWbVyPY6tn5hjSfnoJP-m", + "fillStyle": "hachure", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 1251.3247180922672, + "y": 265.2518101499975, + "strokeColor": "#000000", + "backgroundColor": "transparent", + "width": 252.57138061523438, + "height": 386.2856903076172, + "seed": 1372924327, + "groupIds": [], + "roundness": { + "type": 3 + }, + "boundElements": [ + { + "id": "HHLbJVJz_OMr232-JBPf1", + "type": "arrow" + } + ], + "updated": 1682249347481, + "link": null, + "locked": false + }, + { + "type": "text", + "version": 372, + "versionNonce": 1710888135, + "isDeleted": false, + "id": "GxuYjwVMlxohNwdQ7y1eN", + "fillStyle": "hachure", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 404.5748556796764, + "y": 65.3858166338153, + "strokeColor": "#000000", + "backgroundColor": "transparent", + "width": 980.7642822265625, + "height": 125.21561977532407, + "seed": 1151070311, + "groupIds": [], + "roundness": null, + "boundElements": [], + "updated": 1682184409673, + "link": null, + "locked": false, + "fontSize": 100.17249582025926, + "fontFamily": 1, + "text": "Bowling Score Card ", + "textAlign": "left", + "verticalAlign": "top", + "containerId": null, + "originalText": "Bowling Score Card ", + "lineHeight": 1.25, + "baseline": 88 + }, + { + "type": "text", + "version": 145, + "versionNonce": 1644305513, + "isDeleted": false, + "id": "c-OfAgdyixldDRnj6EXnt", + "fillStyle": "hachure", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 806.3963356160242, + "y": 199.64131973713998, + "strokeColor": "#000000", + "backgroundColor": "transparent", + "width": 116.71194458007812, + "height": 45, + "seed": 1407232457, + "groupIds": [], + "roundness": null, + "boundElements": [], + "updated": 1682182562986, + "link": null, + "locked": false, + "fontSize": 36, + "fontFamily": 1, + "text": "Models", + "textAlign": "left", + "verticalAlign": "top", + "containerId": null, + "originalText": "Models", + "lineHeight": 1.25, + "baseline": 31 + }, + { + "type": "text", + "version": 609, + "versionNonce": 1464272319, + "isDeleted": false, + "id": "z7sKrFRpV_zH3cwtu5LB2", + "fillStyle": "hachure", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 770.8181713159576, + "y": 264.0192671041692, + "strokeColor": "#000000", + "backgroundColor": "transparent", + "width": 188.98606872558594, + "height": 43.34997471986635, + "seed": 1759832199, + "groupIds": [], + "roundness": null, + "boundElements": [], + "updated": 1682249493517, + "link": null, + "locked": false, + "fontSize": 34.67997977589308, + "fontFamily": 1, + "text": "Score Card", + "textAlign": "left", + "verticalAlign": "top", + "containerId": null, + "originalText": "Score Card", + "lineHeight": 1.25, + "baseline": 30 + }, + { + "type": "text", + "version": 1311, + "versionNonce": 1759803825, + "isDeleted": false, + "id": "TRMekqlidvOgnqoHv50KS", + "fillStyle": "hachure", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 756.3675211404047, + "y": 462.3305427235234, + "strokeColor": "#000000", + "backgroundColor": "transparent", + "width": 220.2718963623047, + "height": 80, + "seed": 58433767, + "groupIds": [], + "roundness": null, + "boundElements": [], + "updated": 1682249493517, + "link": null, + "locked": false, + "fontSize": 16, + "fontFamily": 1, + "text": "Called at the end of each\nframe, might not be \nfinal as can depend on the \nfollowing frame.", + "textAlign": "left", + "verticalAlign": "top", + "containerId": null, + "originalText": "Called at the end of each\nframe, might not be \nfinal as can depend on the \nfollowing frame.", + "lineHeight": 1.25, + "baseline": 74 + }, + { + "type": "text", + "version": 755, + "versionNonce": 1914199665, + "isDeleted": false, + "id": "3D_393xKMvdzRpXCEfmmh", + "fillStyle": "hachure", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 1329.4333740761563, + "y": 284.7231124579074, + "strokeColor": "#000000", + "backgroundColor": "transparent", + "width": 86.641845703125, + "height": 37.98830377556801, + "seed": 1560096361, + "groupIds": [], + "roundness": null, + "boundElements": [], + "updated": 1682249347481, + "link": null, + "locked": false, + "fontSize": 30.390643020454412, + "fontFamily": 1, + "text": "Frame", + "textAlign": "left", + "verticalAlign": "top", + "containerId": null, + "originalText": "Frame", + "lineHeight": 1.25, + "baseline": 26 + }, + { + "type": "text", + "version": 604, + "versionNonce": 553106719, + "isDeleted": false, + "id": "CIGZj3oB28UeT9sRGbBGe", + "fillStyle": "hachure", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0.007931909082234512, + "x": 1081.4462422049346, + "y": 397.03835720667274, + "strokeColor": "#000000", + "backgroundColor": "transparent", + "width": 61.439971923828125, + "height": 20, + "seed": 1578984713, + "groupIds": [], + "roundness": null, + "boundElements": [], + "updated": 1682249347481, + "link": null, + "locked": false, + "fontSize": 16, + "fontFamily": 1, + "text": "Has ten", + "textAlign": "left", + "verticalAlign": "top", + "containerId": null, + "originalText": "Has ten", + "lineHeight": 1.25, + "baseline": 14 + }, + { + "type": "text", + "version": 757, + "versionNonce": 1006766289, + "isDeleted": false, + "id": "9qaGbjVB-K_pwHAoIj2ur", + "fillStyle": "hachure", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 1265.4705410529896, + "y": 318.7773359457549, + "strokeColor": "#c92a2a", + "backgroundColor": "transparent", + "width": 50.031951904296875, + "height": 20, + "seed": 564150119, + "groupIds": [], + "roundness": null, + "boundElements": [], + "updated": 1682249805794, + "link": null, + "locked": false, + "fontSize": 16, + "fontFamily": 1, + "text": "Attr -", + "textAlign": "left", + "verticalAlign": "top", + "containerId": null, + "originalText": "Attr -", + "lineHeight": 1.25, + "baseline": 14 + }, + { + "type": "text", + "version": 724, + "versionNonce": 1048627345, + "isDeleted": false, + "id": "I0yMoa8VrMMU4uoWFnxmj", + "fillStyle": "hachure", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 1272.2861499494907, + "y": 342.78997740979827, + "strokeColor": "#862e9c", + "backgroundColor": "transparent", + "width": 129.9999237060547, + "height": 80, + "seed": 1887302985, + "groupIds": [], + "roundness": null, + "boundElements": [], + "updated": 1682249816021, + "link": null, + "locked": false, + "fontSize": 16, + "fontFamily": 1, + "text": "frame_num = int\nscore = []\nmessage = str\nstr_rep = []", + "textAlign": "left", + "verticalAlign": "top", + "containerId": null, + "originalText": "frame_num = int\nscore = []\nmessage = str\nstr_rep = []", + "lineHeight": 1.25, + "baseline": 74 + }, + { + "type": "text", + "version": 754, + "versionNonce": 262822161, + "isDeleted": false, + "id": "8QKQrSId9-dKgO8l36USs", + "fillStyle": "hachure", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 1260.6200213994402, + "y": 473.0359207453274, + "strokeColor": "#c92a2a", + "backgroundColor": "transparent", + "width": 79.18394470214844, + "height": 20, + "seed": 1452697065, + "groupIds": [], + "roundness": null, + "boundElements": [], + "updated": 1682249797588, + "link": null, + "locked": false, + "fontSize": 16, + "fontFamily": 1, + "text": "Methods -", + "textAlign": "left", + "verticalAlign": "top", + "containerId": null, + "originalText": "Methods -", + "lineHeight": 1.25, + "baseline": 14 + }, + { + "type": "text", + "version": 1483, + "versionNonce": 1138976351, + "isDeleted": false, + "id": "ZlobodIqapT1hNSJ8ZBc6", + "fillStyle": "hachure", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 750.3083480228383, + "y": 618.1658547318384, + "strokeColor": "#087f5b", + "backgroundColor": "transparent", + "width": 75.02394104003906, + "height": 20, + "seed": 1623163369, + "groupIds": [], + "roundness": null, + "boundElements": [], + "updated": 1682250321334, + "link": null, + "locked": false, + "fontSize": 16, + "fontFamily": 1, + "text": "message?:", + "textAlign": "left", + "verticalAlign": "top", + "containerId": null, + "originalText": "message?:", + "lineHeight": 1.25, + "baseline": 14 + }, + { + "type": "text", + "version": 1211, + "versionNonce": 834168049, + "isDeleted": false, + "id": "QPXY5bgoe1hKaqfCqJKrf", + "fillStyle": "hachure", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 1262.1285059687243, + "y": 424.93636553433385, + "strokeColor": "#000000", + "backgroundColor": "transparent", + "width": 226.52291870117188, + "height": 46.5330564104862, + "seed": 1037987591, + "groupIds": [], + "roundness": null, + "boundElements": [], + "updated": 1682250498243, + "link": null, + "locked": false, + "fontSize": 12.408815042796322, + "fontFamily": 1, + "text": "score - two INTS representing rolls\nstr_rep - two CHAR representing roll\nscore for printing.", + "textAlign": "left", + "verticalAlign": "top", + "containerId": null, + "originalText": "score - two INTS representing rolls\nstr_rep - two CHAR representing roll\nscore for printing.", + "lineHeight": 1.25, + "baseline": 42 + }, + { + "type": "text", + "version": 295, + "versionNonce": 1627256287, + "isDeleted": false, + "id": "bSLB7VFiTqVNSQRrSXDg1", + "fillStyle": "hachure", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 753.6697654305519, + "y": 312.61003848152893, + "strokeColor": "#c92a2a", + "backgroundColor": "transparent", + "width": 50.031951904296875, + "height": 20, + "seed": 1041292841, + "groupIds": [], + "roundness": null, + "boundElements": [], + "updated": 1682249493517, + "link": null, + "locked": false, + "fontSize": 16, + "fontFamily": 1, + "text": "Attr -", + "textAlign": "left", + "verticalAlign": "top", + "containerId": null, + "originalText": "Attr -", + "lineHeight": 1.25, + "baseline": 14 + }, + { + "type": "text", + "version": 396, + "versionNonce": 778836881, + "isDeleted": false, + "id": "qjQ5jAuboyIizBpzAI3St", + "fillStyle": "hachure", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 760.0924525813806, + "y": 335.0232938889528, + "strokeColor": "#862e9c", + "backgroundColor": "transparent", + "width": 94.62393188476562, + "height": 20, + "seed": 1662263913, + "groupIds": [], + "roundness": null, + "boundElements": [], + "updated": 1682249493517, + "link": null, + "locked": false, + "fontSize": 16, + "fontFamily": 1, + "text": "frames = []", + "textAlign": "left", + "verticalAlign": "top", + "containerId": null, + "originalText": "frames = []", + "lineHeight": 1.25, + "baseline": 14 + }, + { + "type": "text", + "version": 948, + "versionNonce": 1386340863, + "isDeleted": false, + "id": "QiA2LY3adBYMKPObPOOdg", + "fillStyle": "hachure", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 748.0904905432002, + "y": 420.6631361751619, + "strokeColor": "#c92a2a", + "backgroundColor": "transparent", + "width": 79.18394470214844, + "height": 20, + "seed": 1452697065, + "groupIds": [], + "roundness": null, + "boundElements": [], + "updated": 1682249493517, + "link": null, + "locked": false, + "fontSize": 16, + "fontFamily": 1, + "text": "Methods -", + "textAlign": "left", + "verticalAlign": "top", + "containerId": null, + "originalText": "Methods -", + "lineHeight": 1.25, + "baseline": 14 + }, + { + "type": "text", + "version": 283, + "versionNonce": 6609471, + "isDeleted": false, + "id": "dA8ziOzQsTdqovYCNZ3ax", + "fillStyle": "hachure", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 1574.6651510864338, + "y": 285.62403842462857, + "strokeColor": "#000000", + "backgroundColor": "transparent", + "width": 407.82373046875, + "height": 40, + "seed": 1870927975, + "groupIds": [], + "roundness": null, + "boundElements": [], + "updated": 1682249369764, + "link": null, + "locked": false, + "fontSize": 16, + "fontFamily": 1, + "text": "Could you give int itself a special method \nwithin the program that talks to the overall game?", + "textAlign": "left", + "verticalAlign": "top", + "containerId": null, + "originalText": "Could you give int itself a special method \nwithin the program that talks to the overall game?", + "lineHeight": 1.25, + "baseline": 34 + }, + { + "type": "text", + "version": 415, + "versionNonce": 174358897, + "isDeleted": false, + "id": "e3fKD-VuqrLGxGP92YeKC", + "fillStyle": "hachure", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 758.9651140756955, + "y": 355.3479775656469, + "strokeColor": "#000000", + "backgroundColor": "transparent", + "width": 214.73585510253906, + "height": 20, + "seed": 1299088903, + "groupIds": [], + "roundness": null, + "boundElements": [], + "updated": 1682249493517, + "link": null, + "locked": false, + "fontSize": 16, + "fontFamily": 1, + "text": "an array of frame objects.", + "textAlign": "left", + "verticalAlign": "top", + "containerId": null, + "originalText": "an array of frame objects.", + "lineHeight": 1.25, + "baseline": 14 + }, + { + "id": "mfu1CtV6ZaqJNiA4i8_ww", + "type": "text", + "x": 514.094456134267, + "y": 722.7056314838852, + "width": 764.619384765625, + "height": 125, + "angle": 0, + "strokeColor": "#000000", + "backgroundColor": "transparent", + "fillStyle": "hachure", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "groupIds": [], + "roundness": null, + "seed": 775779953, + "version": 448, + "versionNonce": 2033756177, + "isDeleted": false, + "boundElements": null, + "updated": 1682208194981, + "link": null, + "locked": false, + "text": "First step and test. See how complex it would be to write an algorithm that\nwill add up a perfect game to 300.\n\nFrom there the two follow up cases will be taken from the Makers spec and\nmyactivesg.com (a Singaporean sport website). ", + "fontSize": 20, + "fontFamily": 1, + "textAlign": "left", + "verticalAlign": "top", + "baseline": 117, + "containerId": null, + "originalText": "First step and test. See how complex it would be to write an algorithm that\nwill add up a perfect game to 300.\n\nFrom there the two follow up cases will be taken from the Makers spec and\nmyactivesg.com (a Singaporean sport website). ", + "lineHeight": 1.25 + }, + { + "id": "J2pjnSlzMbNnJgw6QO9n_", + "type": "text", + "x": 749.8073268130987, + "y": 439.46999369693094, + "width": 143.0598602294922, + "height": 25, + "angle": 0, + "strokeColor": "#087f5b", + "backgroundColor": "transparent", + "fillStyle": "hachure", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "groupIds": [], + "roundness": null, + "seed": 2115318527, + "version": 347, + "versionNonce": 489900575, + "isDeleted": false, + "boundElements": null, + "updated": 1682249493517, + "link": null, + "locked": false, + "text": "current_score:", + "fontSize": 20, + "fontFamily": 1, + "textAlign": "left", + "verticalAlign": "top", + "baseline": 17, + "containerId": null, + "originalText": "current_score:", + "lineHeight": 1.25 + }, + { + "id": "5akfPxNVTT9-3AP1NAxmk", + "type": "text", + "x": 255.16538832605988, + "y": 405.0419597562493, + "width": 104.35775756835938, + "height": 21.092553008406306, + "angle": 0, + "strokeColor": "#087f5b", + "backgroundColor": "transparent", + "fillStyle": "hachure", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "groupIds": [], + "roundness": null, + "seed": 105980287, + "version": 663, + "versionNonce": 266671537, + "isDeleted": false, + "boundElements": null, + "updated": 1682249347481, + "link": null, + "locked": false, + "text": "start_game:", + "fontSize": 16.874042406725046, + "fontFamily": 1, + "textAlign": "left", + "verticalAlign": "top", + "baseline": 14, + "containerId": null, + "originalText": "start_game:", + "lineHeight": 1.25 + }, + { + "id": "SACYJbd_YTVcoNItmOuYA", + "type": "text", + "x": 258.9890029453856, + "y": 425.44316079467933, + "width": 233.51986694335938, + "height": 40, + "angle": 0, + "strokeColor": "#000000", + "backgroundColor": "transparent", + "fillStyle": "hachure", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "groupIds": [], + "roundness": null, + "seed": 1393814673, + "version": 669, + "versionNonce": 484776415, + "isDeleted": false, + "boundElements": null, + "updated": 1682249347481, + "link": null, + "locked": false, + "text": "Handles user count scorecard\nand UI", + "fontSize": 16, + "fontFamily": 1, + "textAlign": "left", + "verticalAlign": "top", + "baseline": 34, + "containerId": null, + "originalText": "Handles user count scorecard\nand UI", + "lineHeight": 1.25 + }, + { + "id": "Vp2tMQcu13L4fw_h6GoMq", + "type": "text", + "x": 749.5385926395337, + "y": 541.075147934392, + "width": 90.17591857910156, + "height": 20, + "angle": 0, + "strokeColor": "#087f5b", + "backgroundColor": "transparent", + "fillStyle": "hachure", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "groupIds": [], + "roundness": null, + "seed": 549623903, + "version": 620, + "versionNonce": 1465566161, + "isDeleted": false, + "boundElements": null, + "updated": 1682250314472, + "link": null, + "locked": false, + "text": "add_frame:", + "fontSize": 16, + "fontFamily": 1, + "textAlign": "left", + "verticalAlign": "top", + "baseline": 14, + "containerId": null, + "originalText": "add_frame:", + "lineHeight": 1.25 + }, + { + "type": "rectangle", + "version": 1211, + "versionNonce": 1308919295, + "isDeleted": false, + "id": "fFwjRD6Z6byh7-fm913SA", + "fillStyle": "hachure", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 246.3262582312468, + "y": 276.10396026201244, + "strokeColor": "#000000", + "backgroundColor": "transparent", + "width": 252.57138061523438, + "height": 378.63787759606373, + "seed": 1372924327, + "groupIds": [], + "roundness": { + "type": 3 + }, + "boundElements": [ + { + "id": "jX8kezK-o62a31VQkw-qd", + "type": "arrow" + } + ], + "updated": 1682249347481, + "link": null, + "locked": false + }, + { + "id": "2v9ibrvznIWR40cih14BJ", + "type": "text", + "x": 752.1288925547929, + "y": 559.5743589753537, + "width": 235.8558349609375, + "height": 20, + "angle": 0, + "strokeColor": "#000000", + "backgroundColor": "transparent", + "fillStyle": "hachure", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "groupIds": [], + "roundness": null, + "seed": 1711404209, + "version": 399, + "versionNonce": 1034071615, + "isDeleted": false, + "boundElements": null, + "updated": 1682249493517, + "link": null, + "locked": false, + "text": "adds a frame to score_card.", + "fontSize": 16, + "fontFamily": 1, + "textAlign": "left", + "verticalAlign": "top", + "baseline": 14, + "containerId": null, + "originalText": "adds a frame to score_card.", + "lineHeight": 1.25 + }, + { + "id": "jX8kezK-o62a31VQkw-qd", + "type": "arrow", + "x": 504.2356659182087, + "y": 436.0214713826381, + "width": 216.07306516484073, + "height": 4.413127780986315, + "angle": 0, + "strokeColor": "#000000", + "backgroundColor": "transparent", + "fillStyle": "hachure", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "groupIds": [], + "roundness": { + "type": 2 + }, + "seed": 883177201, + "version": 2092, + "versionNonce": 964971999, + "isDeleted": false, + "boundElements": null, + "updated": 1682249459599, + "link": null, + "locked": false, + "points": [ + [ + 0, + 0 + ], + [ + 216.07306516484073, + 4.413127780986315 + ] + ], + "lastCommittedPoint": null, + "startBinding": { + "elementId": "fFwjRD6Z6byh7-fm913SA", + "gap": 5.338027071727538, + "focus": -0.16636599279031644 + }, + "endBinding": { + "elementId": "Br-XRAEs2P0LbQeJ2Euww", + "gap": 16.840546967054024, + "focus": 0.1287259190244708 + }, + "startArrowhead": null, + "endArrowhead": "arrow" + }, + { + "id": "HCOSYUST3qkwvo3vxUna5", + "type": "text", + "x": 578.5533186247056, + "y": 405.607007597946, + "width": 64.3199462890625, + "height": 20, + "angle": 0, + "strokeColor": "#000000", + "backgroundColor": "transparent", + "fillStyle": "hachure", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "groupIds": [], + "roundness": null, + "seed": 1339373951, + "version": 578, + "versionNonce": 656476031, + "isDeleted": false, + "boundElements": [ + { + "id": "jX8kezK-o62a31VQkw-qd", + "type": "arrow" + } + ], + "updated": 1682249405780, + "link": null, + "locked": false, + "text": "Controls", + "fontSize": 16, + "fontFamily": 1, + "textAlign": "left", + "verticalAlign": "top", + "baseline": 14, + "containerId": null, + "originalText": "Controls", + "lineHeight": 1.25 + }, + { + "id": "Fs_Sefk1iV5gGmMArur-P", + "type": "text", + "x": 761.0398365775594, + "y": 377.4912208262193, + "width": 158.83189392089844, + "height": 20, + "angle": 0, + "strokeColor": "#862e9c", + "backgroundColor": "transparent", + "fillStyle": "hachure", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "groupIds": [], + "roundness": null, + "seed": 1908786591, + "version": 349, + "versionNonce": 1708497201, + "isDeleted": false, + "boundElements": null, + "updated": 1682249493517, + "link": null, + "locked": false, + "text": "frame_bonuses = []", + "fontSize": 16, + "fontFamily": 1, + "textAlign": "left", + "verticalAlign": "top", + "baseline": 14, + "containerId": null, + "originalText": "frame_bonuses = []", + "lineHeight": 1.25 + }, + { + "id": "4ekLkk8ScAMYl_MRypebP", + "type": "text", + "x": 759.2643868850205, + "y": 400.98061455498646, + "width": 222.7838592529297, + "height": 20, + "angle": 0, + "strokeColor": "#000000", + "backgroundColor": "transparent", + "fillStyle": "hachure", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "groupIds": [], + "roundness": null, + "seed": 1937973041, + "version": 315, + "versionNonce": 1053855327, + "isDeleted": false, + "boundElements": null, + "updated": 1682249493517, + "link": null, + "locked": false, + "text": "bonus points for each frame", + "fontSize": 16, + "fontFamily": 1, + "textAlign": "left", + "verticalAlign": "top", + "baseline": 14, + "containerId": null, + "originalText": "bonus points for each frame", + "lineHeight": 1.25 + }, + { + "id": "VrKCGo5x9PAOx2GJpI53C", + "type": "text", + "x": 749.1232605187963, + "y": 578.5737172782852, + "width": 90.27194213867188, + "height": 20, + "angle": 0, + "strokeColor": "#087f5b", + "backgroundColor": "transparent", + "fillStyle": "hachure", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "groupIds": [], + "roundness": null, + "seed": 1268730079, + "version": 355, + "versionNonce": 1548073471, + "isDeleted": false, + "boundElements": null, + "updated": 1682250317963, + "link": null, + "locked": false, + "text": "calc_bonus:", + "fontSize": 16, + "fontFamily": 1, + "textAlign": "left", + "verticalAlign": "top", + "baseline": 14, + "containerId": null, + "originalText": "calc_bonus:", + "lineHeight": 1.25 + }, + { + "id": "czMqVEUrjlGHoXbSuNs4h", + "type": "text", + "x": 752.1628215040253, + "y": 598.4549759753082, + "width": 219.7438507080078, + "height": 20, + "angle": 0, + "strokeColor": "#000000", + "backgroundColor": "transparent", + "fillStyle": "hachure", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "groupIds": [], + "roundness": null, + "seed": 1121498225, + "version": 377, + "versionNonce": 2072865407, + "isDeleted": false, + "boundElements": null, + "updated": 1682249493517, + "link": null, + "locked": false, + "text": "calculates bonus per frame.", + "fontSize": 16, + "fontFamily": 1, + "textAlign": "left", + "verticalAlign": "top", + "baseline": 14, + "containerId": null, + "originalText": "calculates bonus per frame.", + "lineHeight": 1.25 + }, + { + "id": "jbq6uAST9CFQg9p9NLznl", + "type": "text", + "x": 750.1871081829343, + "y": 639.6270913463377, + "width": 220.14382934570312, + "height": 40, + "angle": 0, + "strokeColor": "#000000", + "backgroundColor": "transparent", + "fillStyle": "hachure", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "groupIds": [], + "roundness": null, + "seed": 1174660927, + "version": 124, + "versionNonce": 1305661425, + "isDeleted": false, + "boundElements": null, + "updated": 1682249681626, + "link": null, + "locked": false, + "text": "applies bonus message if\napplicable to frame.message", + "fontSize": 16, + "fontFamily": 1, + "textAlign": "left", + "verticalAlign": "top", + "baseline": 34, + "containerId": null, + "originalText": "applies bonus message if\napplicable to frame.message", + "lineHeight": 1.25 + }, + { + "id": "ggLmvm8uuvJLEKeEg-4jA", + "type": "text", + "x": 268.7533636078026, + "y": 286.7561327541577, + "width": 207.97193908691406, + "height": 45, + "angle": 0, + "strokeColor": "#000000", + "backgroundColor": "transparent", + "fillStyle": "hachure", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "groupIds": [], + "roundness": null, + "seed": 180112881, + "version": 60, + "versionNonce": 443012447, + "isDeleted": false, + "boundElements": null, + "updated": 1682249882052, + "link": null, + "locked": false, + "text": "Score Game", + "fontSize": 36, + "fontFamily": 1, + "textAlign": "left", + "verticalAlign": "top", + "baseline": 31, + "containerId": null, + "originalText": "Score Game", + "lineHeight": 1.25 + }, + { + "id": "FFh-gWpeHnrYZD6Q9ZuzX", + "type": "text", + "x": 1261.8273930302948, + "y": 492.7402371588171, + "width": 70.1279296875, + "height": 20, + "angle": 0, + "strokeColor": "#862e9c", + "backgroundColor": "transparent", + "fillStyle": "hachure", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "groupIds": [], + "roundness": null, + "seed": 725420145, + "version": 92, + "versionNonce": 1237879647, + "isDeleted": false, + "boundElements": null, + "updated": 1682250005377, + "link": null, + "locked": false, + "text": "add_roll:", + "fontSize": 16, + "fontFamily": 1, + "textAlign": "left", + "verticalAlign": "top", + "baseline": 14, + "containerId": null, + "originalText": "add_roll:", + "lineHeight": 1.25 + }, + { + "id": "YkoZAI00g0dhsoztEXySr", + "type": "text", + "x": 1262.7478042815155, + "y": 511.87511757187747, + "width": 227.31185913085938, + "height": 40, + "angle": 0, + "strokeColor": "#000000", + "backgroundColor": "transparent", + "fillStyle": "hachure", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "groupIds": [], + "roundness": null, + "seed": 1439447839, + "version": 171, + "versionNonce": 1670756703, + "isDeleted": false, + "boundElements": null, + "updated": 1682250341793, + "link": null, + "locked": false, + "text": "adds the score for a single \nroll.", + "fontSize": 16, + "fontFamily": 1, + "textAlign": "left", + "verticalAlign": "top", + "baseline": 34, + "containerId": null, + "originalText": "adds the score for a single \nroll.", + "lineHeight": 1.25 + }, + { + "id": "rJXhLD9zlTrswaaUQt9-z", + "type": "text", + "x": 1262.5583962939243, + "y": 554.9373581442934, + "width": 116.35188293457031, + "height": 20, + "angle": 0, + "strokeColor": "#862e9c", + "backgroundColor": "transparent", + "fillStyle": "hachure", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "groupIds": [], + "roundness": null, + "seed": 550236913, + "version": 85, + "versionNonce": 655189617, + "isDeleted": false, + "boundElements": null, + "updated": 1682250338970, + "link": null, + "locked": false, + "text": "write_str_rep:", + "fontSize": 16, + "fontFamily": 1, + "textAlign": "left", + "verticalAlign": "top", + "baseline": 14, + "containerId": null, + "originalText": "write_str_rep:", + "lineHeight": 1.25 + }, + { + "id": "w5kXLp7v-MusAb9TuqT7L", + "type": "text", + "x": 1260.7524563360355, + "y": 578.2550477205514, + "width": 238.99183654785156, + "height": 40, + "angle": 0, + "strokeColor": "#000000", + "backgroundColor": "transparent", + "fillStyle": "hachure", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "groupIds": [], + "roundness": null, + "seed": 1766073777, + "version": 74, + "versionNonce": 2079359441, + "isDeleted": false, + "boundElements": null, + "updated": 1682250329760, + "link": null, + "locked": false, + "text": "writes the string rep when the\nframe complete", + "fontSize": 16, + "fontFamily": 1, + "textAlign": "left", + "verticalAlign": "top", + "baseline": 34, + "containerId": null, + "originalText": "writes the string rep when the\nframe complete", + "lineHeight": 1.25 + } + ], + "appState": { + "gridSize": null, + "viewBackgroundColor": "#ffffff" + }, + "files": {} +} \ No newline at end of file diff --git a/models.rb b/models.rb new file mode 100644 index 00000000..e69de29b From cb0b25ff23b556a43b5bfb7db4ce900352e174a0 Mon Sep 17 00:00:00 2001 From: Jon P Date: Sun, 23 Apr 2023 17:49:22 +0100 Subject: [PATCH 2/4] score calculations (current_score/calc_bonuses duo) passing all current tests, which I think give full coverage. Needs a README to explain design. --- .rspec | 1 + Gemfile | 7 +++ Gemfile.lock | 26 ++++++++++ lib/models.rb | 69 +++++++++++++++++++++++++++ mind_map.excalidraw | 16 +++---- models.rb | 0 spec/models_spec.rb | 112 ++++++++++++++++++++++++++++++++++++++++++++ spec/spec_helper.rb | 98 ++++++++++++++++++++++++++++++++++++++ 8 files changed, 321 insertions(+), 8 deletions(-) create mode 100644 .rspec create mode 100644 Gemfile create mode 100644 Gemfile.lock create mode 100644 lib/models.rb delete mode 100644 models.rb create mode 100644 spec/models_spec.rb create mode 100644 spec/spec_helper.rb diff --git a/.rspec b/.rspec new file mode 100644 index 00000000..c99d2e73 --- /dev/null +++ b/.rspec @@ -0,0 +1 @@ +--require spec_helper diff --git a/Gemfile b/Gemfile new file mode 100644 index 00000000..d2229bfe --- /dev/null +++ b/Gemfile @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +source "https://rubygems.org" + +gem "rspec", "~> 3.12" + +# gem "rails" diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 00000000..1be11966 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,26 @@ +GEM + remote: https://rubygems.org/ + specs: + diff-lcs (1.5.0) + rspec (3.12.0) + rspec-core (~> 3.12.0) + rspec-expectations (~> 3.12.0) + rspec-mocks (~> 3.12.0) + rspec-core (3.12.2) + rspec-support (~> 3.12.0) + rspec-expectations (3.12.3) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.12.0) + rspec-mocks (3.12.5) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.12.0) + rspec-support (3.12.0) + +PLATFORMS + x64-mingw-ucrt + +DEPENDENCIES + rspec (~> 3.12) + +BUNDLED WITH + 2.4.9 diff --git a/lib/models.rb b/lib/models.rb new file mode 100644 index 00000000..f9236646 --- /dev/null +++ b/lib/models.rb @@ -0,0 +1,69 @@ +class Frame + attr_accessor :frame_num, :score, :str_rep, :message + def initialize(frame_num, score=[]) + @frame_num = frame_num + @score = score + @str_rep = [] + @message = "" + end + + def get_score + return @score + end + + def add_roll(roll_score) + @score.push(roll_score) + end + + def str_rep(score) + if @score[0] = 10 + @str_rep = ["", "X"] + elsif @score.sum == 10 + @str_rep = [@score[0].to_s, "/"] + elsif + for i in @score + @str_rep.push(i.to_s) + end + end + end +end + +class ScoreCard + attr_accessor :frames, :frame_bonuses + def initialize + @frames = [] + @frame_bonuses = [] + end + + def add_frame(frame) + @frames.push(frame) + end + + def current_score + frames_total = 0 + @frames.each { |frame| frames_total += frame.score.sum } + self.calc_bonuses + return frames_total + @frame_bonuses.sum + end + + def calc_bonuses + for i in 0...@frames.length + if @frames[i].score[0] == 10 + if @frames[i+1] == nil and @frames[i].frame_num != 9 + return nil + elsif @frames[i].frame_num == 9 + @frame_bonuses.push(@frames[i+1].score[0..1].sum) + return nil + elsif @frames[i+1].score[0] == 10 + @frame_bonuses.push(10+@frames[i+2].score[0]) + else + @frame_bonuses.push(@frames[i+1].score.sum) + end + elsif @frames[i].score.sum == 10 + frame_bonuses.push(@frames[i+1].score[0]) + else + frame_bonuses.push(0) + end + end + end +end \ No newline at end of file diff --git a/mind_map.excalidraw b/mind_map.excalidraw index 532c8bd8..24b900ed 100644 --- a/mind_map.excalidraw +++ b/mind_map.excalidraw @@ -1236,7 +1236,7 @@ "width": 70.1279296875, "height": 20, "angle": 0, - "strokeColor": "#862e9c", + "strokeColor": "#087f5b", "backgroundColor": "transparent", "fillStyle": "hachure", "strokeWidth": 1, @@ -1246,11 +1246,11 @@ "groupIds": [], "roundness": null, "seed": 725420145, - "version": 92, - "versionNonce": 1237879647, + "version": 93, + "versionNonce": 1658467007, "isDeleted": false, "boundElements": null, - "updated": 1682250005377, + "updated": 1682259620746, "link": null, "locked": false, "text": "add_roll:", @@ -1306,7 +1306,7 @@ "width": 116.35188293457031, "height": 20, "angle": 0, - "strokeColor": "#862e9c", + "strokeColor": "#087f5b", "backgroundColor": "transparent", "fillStyle": "hachure", "strokeWidth": 1, @@ -1316,11 +1316,11 @@ "groupIds": [], "roundness": null, "seed": 550236913, - "version": 85, - "versionNonce": 655189617, + "version": 86, + "versionNonce": 1416748689, "isDeleted": false, "boundElements": null, - "updated": 1682250338970, + "updated": 1682259626408, "link": null, "locked": false, "text": "write_str_rep:", diff --git a/models.rb b/models.rb deleted file mode 100644 index e69de29b..00000000 diff --git a/spec/models_spec.rb b/spec/models_spec.rb new file mode 100644 index 00000000..cf734432 --- /dev/null +++ b/spec/models_spec.rb @@ -0,0 +1,112 @@ +require 'models' + +RSpec.describe ScoreCard do + context "ScoreCard scores a perfect game" do + it "returns a score of 300" do + frame_1 = Frame.new(1, [10]) + frame_2 = Frame.new(2, [10]) + frame_3 = Frame.new(3, [10]) + frame_4 = Frame.new(4, [10]) + frame_5 = Frame.new(5, [10]) + frame_6 = Frame.new(6, [10]) + frame_7 = Frame.new(7, [10]) + frame_8 = Frame.new(8, [10]) + frame_9 = Frame.new(9, [10]) + frame_10 = Frame.new(10, [10,10,10]) + score_card = ScoreCard.new + score_card.add_frame(frame_1) + score_card.add_frame(frame_2) + score_card.add_frame(frame_3) + score_card.add_frame(frame_4) + score_card.add_frame(frame_5) + score_card.add_frame(frame_6) + score_card.add_frame(frame_7) + score_card.add_frame(frame_8) + score_card.add_frame(frame_9) + score_card.add_frame(frame_10) + result = score_card.current_score + expect(result).to eq 300 + end + end + context "ScoreCard scores Maker's example" do + it "returns a score of 133" do + frame_1 = Frame.new(1, [1, 4]) + frame_2 = Frame.new(2, [4, 5]) + frame_3 = Frame.new(3, [6, 4]) + frame_4 = Frame.new(4, [5, 5]) + frame_5 = Frame.new(5, [10]) + frame_6 = Frame.new(6, [0, 1]) + frame_7 = Frame.new(7, [7, 3]) + frame_8 = Frame.new(8, [6, 4]) + frame_9 = Frame.new(9, [10]) + frame_10 = Frame.new(10, [2, 8, 6]) + score_card = ScoreCard.new + score_card.add_frame(frame_1) + score_card.add_frame(frame_2) + score_card.add_frame(frame_3) + score_card.add_frame(frame_4) + score_card.add_frame(frame_5) + score_card.add_frame(frame_6) + score_card.add_frame(frame_7) + score_card.add_frame(frame_8) + score_card.add_frame(frame_9) + score_card.add_frame(frame_10) + result = score_card.current_score + expect(result).to eq 133 + end + end + context "ScoreCard scores SGactive example" do + it "returns a score of 187" do + frame_1 = Frame.new(1, [10]) + frame_2 = Frame.new(2, [9, 1]) + frame_3 = Frame.new(3, [5, 5]) + frame_4 = Frame.new(4, [7, 2]) + frame_5 = Frame.new(5, [10]) + frame_6 = Frame.new(6, [10]) + frame_7 = Frame.new(7, [10]) + frame_8 = Frame.new(8, [9, 0]) + frame_9 = Frame.new(9, [8, 2]) + frame_10 = Frame.new(10, [9, 1, 10]) + score_card = ScoreCard.new + score_card.add_frame(frame_1) + score_card.add_frame(frame_2) + score_card.add_frame(frame_3) + score_card.add_frame(frame_4) + score_card.add_frame(frame_5) + score_card.add_frame(frame_6) + score_card.add_frame(frame_7) + score_card.add_frame(frame_8) + score_card.add_frame(frame_9) + score_card.add_frame(frame_10) + result = score_card.current_score + expect(result).to eq 187 + end + end + context "ScoreCard scores SGactive example with player not making last strike/spare (no bonus)" do + it "returns a score of 177" do + frame_1 = Frame.new(1, [10]) + frame_2 = Frame.new(2, [9, 1]) + frame_3 = Frame.new(3, [5, 5]) + frame_4 = Frame.new(4, [7, 2]) + frame_5 = Frame.new(5, [10]) + frame_6 = Frame.new(6, [10]) + frame_7 = Frame.new(7, [10]) + frame_8 = Frame.new(8, [9, 0]) + frame_9 = Frame.new(9, [8, 1]) + frame_10 = Frame.new(10, [9, 1, 10]) + score_card = ScoreCard.new + score_card.add_frame(frame_1) + score_card.add_frame(frame_2) + score_card.add_frame(frame_3) + score_card.add_frame(frame_4) + score_card.add_frame(frame_5) + score_card.add_frame(frame_6) + score_card.add_frame(frame_7) + score_card.add_frame(frame_8) + score_card.add_frame(frame_9) + score_card.add_frame(frame_10) + result = score_card.current_score + expect(result).to eq 177 + end + end +end \ No newline at end of file diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb new file mode 100644 index 00000000..5ae5b696 --- /dev/null +++ b/spec/spec_helper.rb @@ -0,0 +1,98 @@ +# This file was generated by the `rspec --init` command. Conventionally, all +# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. +# The generated `.rspec` file contains `--require spec_helper` which will cause +# this file to always be loaded, without a need to explicitly require it in any +# files. +# +# Given that it is always loaded, you are encouraged to keep this file as +# light-weight as possible. Requiring heavyweight dependencies from this file +# will add to the boot time of your test suite on EVERY test run, even for an +# individual file that may not need all of that loaded. Instead, consider making +# a separate helper file that requires the additional dependencies and performs +# the additional setup, and require it from the spec files that actually need +# it. +# +# See https://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration +RSpec.configure do |config| + # rspec-expectations config goes here. You can use an alternate + # assertion/expectation library such as wrong or the stdlib/minitest + # assertions if you prefer. + config.expect_with :rspec do |expectations| + # This option will default to `true` in RSpec 4. It makes the `description` + # and `failure_message` of custom matchers include text for helper methods + # defined using `chain`, e.g.: + # be_bigger_than(2).and_smaller_than(4).description + # # => "be bigger than 2 and smaller than 4" + # ...rather than: + # # => "be bigger than 2" + expectations.include_chain_clauses_in_custom_matcher_descriptions = true + end + + # rspec-mocks config goes here. You can use an alternate test double + # library (such as bogus or mocha) by changing the `mock_with` option here. + config.mock_with :rspec do |mocks| + # Prevents you from mocking or stubbing a method that does not exist on + # a real object. This is generally recommended, and will default to + # `true` in RSpec 4. + mocks.verify_partial_doubles = true + end + + # This option will default to `:apply_to_host_groups` in RSpec 4 (and will + # have no way to turn it off -- the option exists only for backwards + # compatibility in RSpec 3). It causes shared context metadata to be + # inherited by the metadata hash of host groups and examples, rather than + # triggering implicit auto-inclusion in groups with matching metadata. + config.shared_context_metadata_behavior = :apply_to_host_groups + +# The settings below are suggested to provide a good initial experience +# with RSpec, but feel free to customize to your heart's content. +=begin + # This allows you to limit a spec run to individual examples or groups + # you care about by tagging them with `:focus` metadata. When nothing + # is tagged with `:focus`, all examples get run. RSpec also provides + # aliases for `it`, `describe`, and `context` that include `:focus` + # metadata: `fit`, `fdescribe` and `fcontext`, respectively. + config.filter_run_when_matching :focus + + # Allows RSpec to persist some state between runs in order to support + # the `--only-failures` and `--next-failure` CLI options. We recommend + # you configure your source control system to ignore this file. + config.example_status_persistence_file_path = "spec/examples.txt" + + # Limits the available syntax to the non-monkey patched syntax that is + # recommended. For more details, see: + # https://relishapp.com/rspec/rspec-core/docs/configuration/zero-monkey-patching-mode + config.disable_monkey_patching! + + # This setting enables warnings. It's recommended, but in some cases may + # be too noisy due to issues in dependencies. + config.warnings = true + + # Many RSpec users commonly either run the entire suite or an individual + # file, and it's useful to allow more verbose output when running an + # individual spec file. + if config.files_to_run.one? + # Use the documentation formatter for detailed output, + # unless a formatter has already been configured + # (e.g. via a command-line flag). + config.default_formatter = "doc" + end + + # Print the 10 slowest examples and example groups at the + # end of the spec run, to help surface which specs are running + # particularly slow. + config.profile_examples = 10 + + # Run specs in random order to surface order dependencies. If you find an + # order dependency and want to debug it, you can fix the order by providing + # the seed, which is printed after each run. + # --seed 1234 + config.order = :random + + # Seed global randomization in this process using the `--seed` CLI option. + # Setting this allows you to use `--seed` to deterministically reproduce + # test failures related to randomization by passing the same `--seed` value + # as the one that triggered the failure. + Kernel.srand config.seed +=end +end From 5d321e888bb0e912ab80ea9da8d7fcc282c3d635 Mon Sep 17 00:00:00 2001 From: Jon P Date: Mon, 24 Apr 2023 01:44:51 +0100 Subject: [PATCH 3/4] score_game now working for user input game. All three tests are passing via manual input, need to integrate with RSpec, but a leanring goal beyond tonight. Hope to write a readme in the morning with ccoffee. WIll make pull request tonight, design logic in Excalidraw file. Run app.rb to test input game --- lib/app.rb | 7 ++++++ lib/controllers.rb | 54 ++++++++++++++++++++++++++++++++++++++++++++++ lib/models.rb | 15 ++++++------- 3 files changed, 67 insertions(+), 9 deletions(-) create mode 100644 lib/app.rb create mode 100644 lib/controllers.rb diff --git a/lib/app.rb b/lib/app.rb new file mode 100644 index 00000000..bf56d67c --- /dev/null +++ b/lib/app.rb @@ -0,0 +1,7 @@ +require_relative './controllers' + +card = ScoreCard.new + +scorer = Scorer.new + +scorer.score_game(card) \ No newline at end of file diff --git a/lib/controllers.rb b/lib/controllers.rb new file mode 100644 index 00000000..e51c2cf6 --- /dev/null +++ b/lib/controllers.rb @@ -0,0 +1,54 @@ +require_relative './models' + +class Printer + attr_accessor :score_card + def initialize + end + + def print + return "Frame 5 - You got a STRIKE!" #This was a dummy print to see if I could test for puts output in RSpec. + end +end + +class Scorer + def initialize + end + + def score_game(score_card) + + # populate the score card with frame objects to be written to + for i in (1..10) + frame = Frame.new(i) + score_card.frames.push(frame) + end + + # for each frame, populate each roll with a score. + for i in (0..8) + for n in (0..1) + puts "Please enter the score of your roll from 0-10" + score = gets.chomp.to_i + if score == 10 + score_card.frames[i].score.push(10) + break + else + score_card.frames[i].score.push(score) + end + end + end + for n in (0..1) + puts "This is the last frame" + puts "Please enter the score of your roll from 0-10" + score = gets.chomp.to_i + score_card.frames[9].score.push(score) + if n == 1 && score_card.frames[9].score.sum != 10 + score_card.frames[9].score.push(0) + else + puts "This is the last frame" + puts "Please enter the score of your roll from 0-10" + score = gets.chomp.to_i + score_card.frames[9].score.push(score) + end + end + puts "Your final score is #{score_card.current_score}" + end +end \ No newline at end of file diff --git a/lib/models.rb b/lib/models.rb index f9236646..d520a3a8 100644 --- a/lib/models.rb +++ b/lib/models.rb @@ -7,10 +7,6 @@ def initialize(frame_num, score=[]) @message = "" end - def get_score - return @score - end - def add_roll(roll_score) @score.push(roll_score) end @@ -42,19 +38,20 @@ def add_frame(frame) def current_score frames_total = 0 @frames.each { |frame| frames_total += frame.score.sum } - self.calc_bonuses + self.gen_bonuses return frames_total + @frame_bonuses.sum end - def calc_bonuses - for i in 0...@frames.length + def gen_bonuses + @frame_bonuses = [] + for i in 0...9 if @frames[i].score[0] == 10 if @frames[i+1] == nil and @frames[i].frame_num != 9 return nil elsif @frames[i].frame_num == 9 @frame_bonuses.push(@frames[i+1].score[0..1].sum) return nil - elsif @frames[i+1].score[0] == 10 + elsif @frames[i+1].score[0] == 10 && @frames[i+2] != nil @frame_bonuses.push(10+@frames[i+2].score[0]) else @frame_bonuses.push(@frames[i+1].score.sum) @@ -63,7 +60,7 @@ def calc_bonuses frame_bonuses.push(@frames[i+1].score[0]) else frame_bonuses.push(0) - end + end end end end \ No newline at end of file From 839cfe4f1c36a846cf737ef9307e233f7263c785 Mon Sep 17 00:00:00 2001 From: Jon P Date: Mon, 24 Apr 2023 08:55:21 +0100 Subject: [PATCH 4/4] added design phylosophy to README and excalidraw --- README.md | 16 ++ mind_map.excalidraw | 543 +++++++++++++++++++++++++++++++++------ spec/controllers_spec.rb | 33 +++ spec/models_spec.rb | 2 +- 4 files changed, 520 insertions(+), 74 deletions(-) create mode 100644 spec/controllers_spec.rb diff --git a/README.md b/README.md index 15dc4762..6172daef 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,19 @@ +# J Pillay Implementation and Design Phylosophy + +Each of the objects has a separate function and the models reflect +real world (RW) objects. The data in score card and frame reflect the data +that make up their RW counterparts - any extra data can be extrapolated from +base data eg, messages and bonuses which also need to be reflexive. No base data +recorded is ever mutated or deleted as it may be called upon later and also means +that the score card has persistence and can be used for historical comparison. Integrety +of data is essential to the system. + +With this design the system is very malleable. Print Card (when implemented) can be changed +with different formats without the worry of affecting the underlying program. The same going for +Score Game, which can be changed to accommodate extra players. The program could be changed +to randomise games and throws - thus it may on day even help us answer the age old question... +who is more lucky? Player 1, or 2? A question which will have to wait, for now... + Bowling Challenge in Ruby ================= diff --git a/mind_map.excalidraw b/mind_map.excalidraw index 24b900ed..231c9037 100644 --- a/mind_map.excalidraw +++ b/mind_map.excalidraw @@ -5,8 +5,8 @@ "elements": [ { "type": "rectangle", - "version": 1255, - "versionNonce": 405334431, + "version": 1363, + "versionNonce": 598965681, "isDeleted": false, "id": "Br-XRAEs2P0LbQeJ2Euww", "fillStyle": "hachure", @@ -15,8 +15,8 @@ "roughness": 1, "opacity": 100, "angle": 0, - "x": 737.1492780501035, - "y": 253.99197319197958, + "x": 736.6030307195455, + "y": 255.63083187823395, "strokeColor": "#000000", "backgroundColor": "transparent", "width": 252.57138061523438, @@ -34,16 +34,20 @@ { "id": "jX8kezK-o62a31VQkw-qd", "type": "arrow" + }, + { + "id": "wzfNNWW6srKgrcHim4s6b", + "type": "arrow" } ], - "updated": 1682249459599, + "updated": 1682279654437, "link": null, "locked": false }, { "type": "arrow", - "version": 4643, - "versionNonce": 397958591, + "version": 4857, + "versionNonce": 1876953073, "isDeleted": false, "id": "HHLbJVJz_OMr232-JBPf1", "fillStyle": "hachure", @@ -52,19 +56,19 @@ "roughness": 1, "opacity": 100, "angle": 0, - "x": 1002.8635419661191, - "y": 428.9375011927595, + "x": 1002.3172946355612, + "y": 430.18409834036174, "strokeColor": "#000000", "backgroundColor": "transparent", - "width": 226.88974973454606, - "height": 0.4700975409245416, + "width": 227.43599706510395, + "height": 1.2679169140965314, "seed": 1105884999, "groupIds": [], "roundness": { "type": 2 }, "boundElements": [], - "updated": 1682249459599, + "updated": 1682279647221, "link": null, "locked": false, "startBinding": { @@ -86,8 +90,8 @@ 0 ], [ - 226.88974973454606, - -0.4700975409245416 + 227.43599706510395, + -1.2679169140965314 ] ] }, @@ -161,8 +165,8 @@ }, { "type": "text", - "version": 145, - "versionNonce": 1644305513, + "version": 250, + "versionNonce": 442320593, "isDeleted": false, "id": "c-OfAgdyixldDRnj6EXnt", "fillStyle": "hachure", @@ -171,8 +175,8 @@ "roughness": 1, "opacity": 100, "angle": 0, - "x": 806.3963356160242, - "y": 199.64131973713998, + "x": 1057.6776928204358, + "y": 289.77490077549646, "strokeColor": "#000000", "backgroundColor": "transparent", "width": 116.71194458007812, @@ -181,7 +185,7 @@ "groupIds": [], "roundness": null, "boundElements": [], - "updated": 1682182562986, + "updated": 1682279181826, "link": null, "locked": false, "fontSize": 36, @@ -231,8 +235,8 @@ }, { "type": "text", - "version": 1311, - "versionNonce": 1759803825, + "version": 1316, + "versionNonce": 705698833, "isDeleted": false, "id": "TRMekqlidvOgnqoHv50KS", "fillStyle": "hachure", @@ -251,16 +255,16 @@ "groupIds": [], "roundness": null, "boundElements": [], - "updated": 1682249493517, + "updated": 1682280154309, "link": null, "locked": false, "fontSize": 16, "fontFamily": 1, - "text": "Called at the end of each\nframe, might not be \nfinal as can depend on the \nfollowing frame.", + "text": "Called at the end of each\nframe, might not be \nfinal as can depend on the \nfollowing frame(s).", "textAlign": "left", "verticalAlign": "top", "containerId": null, - "originalText": "Called at the end of each\nframe, might not be \nfinal as can depend on the \nfollowing frame.", + "originalText": "Called at the end of each\nframe, might not be \nfinal as can depend on the \nfollowing frame(s).", "lineHeight": 1.25, "baseline": 74 }, @@ -441,8 +445,8 @@ }, { "type": "text", - "version": 1483, - "versionNonce": 1138976351, + "version": 1485, + "versionNonce": 1646226577, "isDeleted": false, "id": "ZlobodIqapT1hNSJ8ZBc6", "fillStyle": "hachure", @@ -455,29 +459,29 @@ "y": 618.1658547318384, "strokeColor": "#087f5b", "backgroundColor": "transparent", - "width": 75.02394104003906, + "width": 76.25593566894531, "height": 20, "seed": 1623163369, "groupIds": [], "roundness": null, "boundElements": [], - "updated": 1682250321334, + "updated": 1682280113244, "link": null, "locked": false, "fontSize": 16, "fontFamily": 1, - "text": "message?:", + "text": "messages:", "textAlign": "left", "verticalAlign": "top", "containerId": null, - "originalText": "message?:", + "originalText": "messages:", "lineHeight": 1.25, "baseline": 14 }, { "type": "text", - "version": 1211, - "versionNonce": 834168049, + "version": 1214, + "versionNonce": 1564849649, "isDeleted": false, "id": "QPXY5bgoe1hKaqfCqJKrf", "fillStyle": "hachure", @@ -490,22 +494,22 @@ "y": 424.93636553433385, "strokeColor": "#000000", "backgroundColor": "transparent", - "width": 226.52291870117188, + "width": 233.256103515625, "height": 46.5330564104862, "seed": 1037987591, "groupIds": [], "roundness": null, "boundElements": [], - "updated": 1682250498243, + "updated": 1682279420106, "link": null, "locked": false, "fontSize": 12.408815042796322, "fontFamily": 1, - "text": "score - two INTS representing rolls\nstr_rep - two CHAR representing roll\nscore for printing.", + "text": "score - two INTs representing rolls\nstr_rep - two CHARs representing roll\nscore for printing.", "textAlign": "left", "verticalAlign": "top", "containerId": null, - "originalText": "score - two INTS representing rolls\nstr_rep - two CHAR representing roll\nscore for printing.", + "originalText": "score - two INTs representing rolls\nstr_rep - two CHARs representing roll\nscore for printing.", "lineHeight": 1.25, "baseline": 42 }, @@ -687,8 +691,8 @@ { "id": "mfu1CtV6ZaqJNiA4i8_ww", "type": "text", - "x": 514.094456134267, - "y": 722.7056314838852, + "x": 829.8348654578106, + "y": 726.5294503187265, "width": 764.619384765625, "height": 125, "angle": 0, @@ -702,11 +706,11 @@ "groupIds": [], "roundness": null, "seed": 775779953, - "version": 448, - "versionNonce": 2033756177, + "version": 567, + "versionNonce": 1517114865, "isDeleted": false, "boundElements": null, - "updated": 1682208194981, + "updated": 1682322111522, "link": null, "locked": false, "text": "First step and test. See how complex it would be to write an algorithm that\nwill add up a perfect game to 300.\n\nFrom there the two follow up cases will be taken from the Makers spec and\nmyactivesg.com (a Singaporean sport website). ", @@ -757,8 +761,8 @@ { "id": "5akfPxNVTT9-3AP1NAxmk", "type": "text", - "x": 255.16538832605988, - "y": 405.0419597562493, + "x": 253.98022396195728, + "y": 362.79458399337574, "width": 104.35775756835938, "height": 21.092553008406306, "angle": 0, @@ -772,11 +776,11 @@ "groupIds": [], "roundness": null, "seed": 105980287, - "version": 663, - "versionNonce": 266671537, + "version": 816, + "versionNonce": 1984383505, "isDeleted": false, "boundElements": null, - "updated": 1682249347481, + "updated": 1682291490039, "link": null, "locked": false, "text": "start_game:", @@ -792,9 +796,9 @@ { "id": "SACYJbd_YTVcoNItmOuYA", "type": "text", - "x": 258.9890029453856, - "y": 425.44316079467933, - "width": 233.51986694335938, + "x": 257.803838581283, + "y": 383.19578503180577, + "width": 215.4238739013672, "height": 40, "angle": 0, "strokeColor": "#000000", @@ -807,21 +811,21 @@ "groupIds": [], "roundness": null, "seed": 1393814673, - "version": 669, - "versionNonce": 484776415, + "version": 864, + "versionNonce": 1101754975, "isDeleted": false, "boundElements": null, - "updated": 1682249347481, + "updated": 1682291570707, "link": null, "locked": false, - "text": "Handles user count scorecard\nand UI", + "text": "Handles object initialisation\nand UI.", "fontSize": 16, "fontFamily": 1, "textAlign": "left", "verticalAlign": "top", "baseline": 34, "containerId": null, - "originalText": "Handles user count scorecard\nand UI", + "originalText": "Handles object initialisation\nand UI.", "lineHeight": 1.25 }, { @@ -861,8 +865,8 @@ }, { "type": "rectangle", - "version": 1211, - "versionNonce": 1308919295, + "version": 1361, + "versionNonce": 793607313, "isDeleted": false, "id": "fFwjRD6Z6byh7-fm913SA", "fillStyle": "hachure", @@ -871,8 +875,8 @@ "roughness": 1, "opacity": 100, "angle": 0, - "x": 246.3262582312468, - "y": 276.10396026201244, + "x": 243.59490488387638, + "y": 279.92780827049893, "strokeColor": "#000000", "backgroundColor": "transparent", "width": 252.57138061523438, @@ -886,9 +890,13 @@ { "id": "jX8kezK-o62a31VQkw-qd", "type": "arrow" + }, + { + "id": "UmeVIm2XxM0CZLTmQyyT9", + "type": "arrow" } ], - "updated": 1682249347481, + "updated": 1682279673857, "link": null, "locked": false }, @@ -930,10 +938,10 @@ { "id": "jX8kezK-o62a31VQkw-qd", "type": "arrow", - "x": 504.2356659182087, - "y": 436.0214713826381, - "width": 216.07306516484073, - "height": 4.413127780986315, + "x": 501.50431257083824, + "y": 439.61156941286396, + "width": 218.2581711816532, + "height": 3.3042407212637954, "angle": 0, "strokeColor": "#000000", "backgroundColor": "transparent", @@ -947,11 +955,11 @@ "type": 2 }, "seed": 883177201, - "version": 2092, - "versionNonce": 964971999, + "version": 2602, + "versionNonce": 1666965969, "isDeleted": false, "boundElements": null, - "updated": 1682249459599, + "updated": 1682279647221, "link": null, "locked": false, "points": [ @@ -960,8 +968,8 @@ 0 ], [ - 216.07306516484073, - 4.413127780986315 + 218.2581711816532, + 3.3042407212637954 ] ], "lastCommittedPoint": null, @@ -1161,8 +1169,8 @@ { "id": "jbq6uAST9CFQg9p9NLznl", "type": "text", - "x": 750.1871081829343, - "y": 639.6270913463377, + "x": 749.6407441577959, + "y": 638.5345383379315, "width": 220.14382934570312, "height": 40, "angle": 0, @@ -1176,11 +1184,11 @@ "groupIds": [], "roundness": null, "seed": 1174660927, - "version": 124, - "versionNonce": 1305661425, + "version": 134, + "versionNonce": 1721375569, "isDeleted": false, "boundElements": null, - "updated": 1682249681626, + "updated": 1682280191135, "link": null, "locked": false, "text": "applies bonus message if\napplicable to frame.message", @@ -1367,6 +1375,395 @@ "containerId": null, "originalText": "writes the string rep when the\nframe complete", "lineHeight": 1.25 + }, + { + "id": "LUFjg7VvKFSvxvKWtcQIM", + "type": "text", + "x": 257.5251995745877, + "y": 341.0839181859831, + "width": 79.18394470214844, + "height": 20, + "angle": 0, + "strokeColor": "#c92a2a", + "backgroundColor": "transparent", + "fillStyle": "hachure", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "groupIds": [], + "roundness": null, + "seed": 1249789457, + "version": 49, + "versionNonce": 1003872241, + "isDeleted": false, + "boundElements": null, + "updated": 1682291490039, + "link": null, + "locked": false, + "text": "Methods -", + "fontSize": 16, + "fontFamily": 1, + "textAlign": "left", + "verticalAlign": "top", + "baseline": 14, + "containerId": null, + "originalText": "Methods -", + "lineHeight": 1.25 + }, + { + "type": "rectangle", + "version": 1524, + "versionNonce": 175227505, + "isDeleted": false, + "id": "c_bnIAcWAVEO8C2jm55DY", + "fillStyle": "hachure", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 517.7511713306444, + "y": 787.0997689739454, + "strokeColor": "#000000", + "backgroundColor": "transparent", + "width": 252.57138061523438, + "height": 378.63787759606373, + "seed": 1372924327, + "groupIds": [], + "roundness": { + "type": 3 + }, + "boundElements": [ + { + "id": "wzfNNWW6srKgrcHim4s6b", + "type": "arrow" + }, + { + "id": "UmeVIm2XxM0CZLTmQyyT9", + "type": "arrow" + } + ], + "updated": 1682279673857, + "link": null, + "locked": false + }, + { + "id": "qWhxiKmlKhEO4sAQWdPlP", + "type": "text", + "x": 548.7137267440884, + "y": 809.8721469031764, + "width": 185.47193908691406, + "height": 45, + "angle": 0, + "strokeColor": "#000000", + "backgroundColor": "transparent", + "fillStyle": "hachure", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "groupIds": [], + "roundness": null, + "seed": 627313311, + "version": 41, + "versionNonce": 1362296913, + "isDeleted": false, + "boundElements": null, + "updated": 1682279349424, + "link": null, + "locked": false, + "text": "Print Card", + "fontSize": 36, + "fontFamily": 1, + "textAlign": "left", + "verticalAlign": "top", + "baseline": 31, + "containerId": null, + "originalText": "Print Card", + "lineHeight": 1.25 + }, + { + "id": "LeBohKq_bXq_Oxu2FNsLW", + "type": "text", + "x": 526.4533603354316, + "y": 862.1130405362366, + "width": 72.19194030761719, + "height": 20, + "angle": 0, + "strokeColor": "#c92a2a", + "backgroundColor": "transparent", + "fillStyle": "hachure", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "groupIds": [], + "roundness": null, + "seed": 779878161, + "version": 88, + "versionNonce": 1755949425, + "isDeleted": false, + "boundElements": null, + "updated": 1682279607298, + "link": null, + "locked": false, + "text": "Params -", + "fontSize": 16, + "fontFamily": 1, + "textAlign": "left", + "verticalAlign": "top", + "baseline": 14, + "containerId": null, + "originalText": "Params -", + "lineHeight": 1.25 + }, + { + "id": "1yfomiLWUvTxEi4f5tZfI", + "type": "text", + "x": 532.5989053670153, + "y": 884.1000498904533, + "width": 224.44784545898438, + "height": 20, + "angle": 0, + "strokeColor": "#000000", + "backgroundColor": "transparent", + "fillStyle": "hachure", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "groupIds": [], + "roundness": null, + "seed": 1442966737, + "version": 85, + "versionNonce": 387872095, + "isDeleted": false, + "boundElements": null, + "updated": 1682279581961, + "link": null, + "locked": false, + "text": "score_card = ScoreCard obj", + "fontSize": 16, + "fontFamily": 1, + "textAlign": "left", + "verticalAlign": "top", + "baseline": 14, + "containerId": null, + "originalText": "score_card = ScoreCard obj", + "lineHeight": 1.25 + }, + { + "id": "wzfNNWW6srKgrcHim4s6b", + "type": "arrow", + "x": 772.3747020757992, + "y": 706.1205391930239, + "width": 21.850476695222596, + "height": 66.64421648323446, + "angle": 0, + "strokeColor": "#000000", + "backgroundColor": "transparent", + "fillStyle": "hachure", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "groupIds": [], + "roundness": { + "type": 2 + }, + "seed": 2049482687, + "version": 34, + "versionNonce": 1100034527, + "isDeleted": false, + "boundElements": null, + "updated": 1682279654437, + "link": null, + "locked": false, + "points": [ + [ + 0, + 0 + ], + [ + -21.850476695222596, + 66.64421648323446 + ] + ], + "lastCommittedPoint": null, + "startBinding": { + "elementId": "Br-XRAEs2P0LbQeJ2Euww", + "focus": 0.07182620089177946, + "gap": 15.040298574696635 + }, + "endBinding": { + "elementId": "c_bnIAcWAVEO8C2jm55DY", + "focus": 0.21085380928671532, + "gap": 14.335013297687055 + }, + "startArrowhead": null, + "endArrowhead": "arrow" + }, + { + "id": "UmeVIm2XxM0CZLTmQyyT9", + "type": "arrow", + "x": 479.57720576130396, + "y": 669.5209177944134, + "width": 44.24737576287362, + "height": 107.06774423762158, + "angle": 0, + "strokeColor": "#000000", + "backgroundColor": "transparent", + "fillStyle": "hachure", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "groupIds": [], + "roundness": { + "type": 2 + }, + "seed": 896376319, + "version": 125, + "versionNonce": 859442175, + "isDeleted": false, + "boundElements": [ + { + "type": "text", + "id": "Wj5meAsr60kFy2Ltze4UC" + } + ], + "updated": 1682279690828, + "link": null, + "locked": false, + "points": [ + [ + 0, + 0 + ], + [ + 44.24737576287362, + 107.06774423762158 + ] + ], + "lastCommittedPoint": null, + "startBinding": { + "elementId": "fFwjRD6Z6byh7-fm913SA", + "focus": -0.1316724561587354, + "gap": 10.955231927850747 + }, + "endBinding": { + "elementId": "c_bnIAcWAVEO8C2jm55DY", + "focus": -0.1839850369553277, + "gap": 10.511106941910384 + }, + "startArrowhead": null, + "endArrowhead": "arrow" + }, + { + "id": "Wj5meAsr60kFy2Ltze4UC", + "type": "text", + "x": 482.660915615397, + "y": 713.0547899132242, + "width": 38.0799560546875, + "height": 20, + "angle": 0, + "strokeColor": "#000000", + "backgroundColor": "transparent", + "fillStyle": "hachure", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "groupIds": [], + "roundness": null, + "seed": 2105810239, + "version": 94, + "versionNonce": 735272927, + "isDeleted": false, + "boundElements": null, + "updated": 1682279690812, + "link": null, + "locked": false, + "text": "Calls", + "fontSize": 16, + "fontFamily": 1, + "textAlign": "center", + "verticalAlign": "middle", + "baseline": 14, + "containerId": "UmeVIm2XxM0CZLTmQyyT9", + "originalText": "Calls", + "lineHeight": 1.25 + }, + { + "id": "I1AcntoYDwjeJ7A2zEu2E", + "type": "text", + "x": 832.0883107382322, + "y": 890.9923552508742, + "width": 316.83587646484375, + "height": 45, + "angle": 0, + "strokeColor": "#000000", + "backgroundColor": "transparent", + "fillStyle": "hachure", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "groupIds": [], + "roundness": null, + "seed": 940789169, + "version": 25, + "versionNonce": 1746184063, + "isDeleted": false, + "boundElements": null, + "updated": 1682322133637, + "link": null, + "locked": false, + "text": "Design Philosophy ", + "fontSize": 36, + "fontFamily": 1, + "textAlign": "left", + "verticalAlign": "top", + "baseline": 31, + "containerId": null, + "originalText": "Design Philosophy ", + "lineHeight": 1.25 + }, + { + "id": "1SJtMV1kPFJH9Bwm6AQQT", + "type": "text", + "x": 825.2599273698061, + "y": 942.4861676450006, + "width": 772.2874145507812, + "height": 260, + "angle": 0, + "strokeColor": "#000000", + "backgroundColor": "transparent", + "fillStyle": "hachure", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "groupIds": [], + "roundness": null, + "seed": 104993727, + "version": 1431, + "versionNonce": 493359409, + "isDeleted": false, + "boundElements": null, + "updated": 1682322850954, + "link": null, + "locked": false, + "text": "Each of the objects has a separate function and the models reflect\nreal world (RW) objects. The data in score card and frame reflect the data\nthat make up their RW counterparts - any extra data can be extrapolated from \nbase data eg, messages and bonuses which also need to be reflexive. No base data\nrecorded is ever mutated or deleted as it may be called upon later and also means\nthat the score card has persistence and can be used for historical comparison. Integrety\nof data is essential to the system.\n\nWith this design the system is very malleable. Print Card (when implemented) can be changed\nwith different formats without the worry of affecting the underlying program. The same going for\nScore Game, which can be changed to accommodate extra players. The program could be changed\nto randomise games and throws - thus it may on day even help us answer the age old question...\nwho is more lucky? Player 1, or 2? A question which will have to wait, for now...", + "fontSize": 16, + "fontFamily": 1, + "textAlign": "left", + "verticalAlign": "top", + "baseline": 254, + "containerId": null, + "originalText": "Each of the objects has a separate function and the models reflect\nreal world (RW) objects. The data in score card and frame reflect the data\nthat make up their RW counterparts - any extra data can be extrapolated from \nbase data eg, messages and bonuses which also need to be reflexive. No base data\nrecorded is ever mutated or deleted as it may be called upon later and also means\nthat the score card has persistence and can be used for historical comparison. Integrety\nof data is essential to the system.\n\nWith this design the system is very malleable. Print Card (when implemented) can be changed\nwith different formats without the worry of affecting the underlying program. The same going for\nScore Game, which can be changed to accommodate extra players. The program could be changed\nto randomise games and throws - thus it may on day even help us answer the age old question...\nwho is more lucky? Player 1, or 2? A question which will have to wait, for now...", + "lineHeight": 1.25 } ], "appState": { diff --git a/spec/controllers_spec.rb b/spec/controllers_spec.rb new file mode 100644 index 00000000..b86f368c --- /dev/null +++ b/spec/controllers_spec.rb @@ -0,0 +1,33 @@ +require 'controllers' + +RSpec.describe Printer do + context "Checking Printer.print" do + it "puts the corrent score progression without messages (makers example)" do + frame_1 = Frame.new(1, [1, 4]) + frame_2 = Frame.new(2, [4, 5]) + frame_3 = Frame.new(3, [6, 4]) + frame_4 = Frame.new(4, [5, 5]) + frame_5 = Frame.new(5, [10]) + frame_6 = Frame.new(6, [0, 1]) + frame_7 = Frame.new(7, [7, 3]) + frame_8 = Frame.new(8, [6, 4]) + frame_9 = Frame.new(9, [10]) + frame_10 = Frame.new(10, [2, 8, 6]) + score_card = ScoreCard.new + score_card.add_frame(frame_1) + score_card.add_frame(frame_2) + score_card.add_frame(frame_3) + score_card.add_frame(frame_4) + score_card.add_frame(frame_5) + score_card.add_frame(frame_6) + score_card.add_frame(frame_7) + score_card.add_frame(frame_8) + score_card.add_frame(frame_9) + score_card.add_frame(frame_10) + printer = Printer.new + output = StringIO.new + printer.print + #expect(output.string).to include "Frame 5 - You got a STRIKE!" + end + end +end \ No newline at end of file diff --git a/spec/models_spec.rb b/spec/models_spec.rb index cf734432..f6b42455 100644 --- a/spec/models_spec.rb +++ b/spec/models_spec.rb @@ -82,7 +82,7 @@ expect(result).to eq 187 end end - context "ScoreCard scores SGactive example with player not making last strike/spare (no bonus)" do + context "ScoreCard scores SGactive example with player not making last 9th frame strike/spare (no bonus)" do it "returns a score of 177" do frame_1 = Frame.new(1, [10]) frame_2 = Frame.new(2, [9, 1])