diff --git a/.idea/Dart_Functions_BlackJack_Stripped.iml b/.idea/Dart_Functions_BlackJack_Stripped.iml index 90642e6..ae9af97 100644 --- a/.idea/Dart_Functions_BlackJack_Stripped.iml +++ b/.idea/Dart_Functions_BlackJack_Stripped.iml @@ -10,5 +10,6 @@ + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml index 27f18ff..35eb1dd 100644 --- a/.idea/vcs.xml +++ b/.idea/vcs.xml @@ -2,6 +2,5 @@ - \ No newline at end of file diff --git a/bin/BlackJack.dart b/bin/BlackJack.dart index f527eab..4ad1af3 100644 --- a/bin/BlackJack.dart +++ b/bin/BlackJack.dart @@ -8,6 +8,6 @@ import 'package:BlackJack/functions/deal_card.dart'; */ void main() { - + CalculateScore([1,1,1,12]); } diff --git a/lib/functions/card_namer.dart b/lib/functions/card_namer.dart index 34f206a..e8a6368 100644 --- a/lib/functions/card_namer.dart +++ b/lib/functions/card_namer.dart @@ -5,6 +5,6 @@ When given an integer between 1-13, it should return the name of the corresponding card (Ignore the suit) */ -String CardNamer(int i){ +String? CardNamer(int i){ } diff --git a/lib/functions/check_if_busted.dart b/lib/functions/check_if_busted.dart index 4ee9ed6..2464e41 100644 --- a/lib/functions/check_if_busted.dart +++ b/lib/functions/check_if_busted.dart @@ -1,7 +1,6 @@ import 'package:BlackJack/functions/draw_card.dart'; import 'score_function.dart'; - /* Create a function called CheckIfBusted. @@ -23,6 +22,16 @@ if ... true eða false, return true eða false */ -bool CheckIfBusted(List hand){ +bool? CheckIfBusted(List hand) { -} + int? score= 0; + score = CalculateScore(hand); + bool busted = false; + if (score > 21){ + busted = true; + } + else { + busted = false; + } + return busted; +} \ No newline at end of file diff --git a/lib/functions/check_winner.dart b/lib/functions/check_winner.dart index d01e38d..aa5badc 100644 --- a/lib/functions/check_winner.dart +++ b/lib/functions/check_winner.dart @@ -15,6 +15,6 @@ of the user, which should have decreased/increased based on if he won or not. import 'package:BlackJack/functions/functions.dart'; -int CheckWinner(List playerHand, List houseHand, int currentBankRoll, int currentBet){ +int? CheckWinner(List playerHand, List houseHand, int currentBankRoll, int currentBet){ } \ No newline at end of file diff --git a/lib/functions/deal_card.dart b/lib/functions/deal_card.dart index 3b88502..cb6bf9b 100644 --- a/lib/functions/deal_card.dart +++ b/lib/functions/deal_card.dart @@ -12,6 +12,6 @@ print(deck); // Should print [2, 3, 4] */ -int DealCard(List deck){ +int? DealCard(List deck){ } \ No newline at end of file diff --git a/lib/functions/deck_of_cards.dart b/lib/functions/deck_of_cards.dart index 9e6fb11..ad8d9a5 100644 --- a/lib/functions/deck_of_cards.dart +++ b/lib/functions/deck_of_cards.dart @@ -8,7 +8,7 @@ the number 2 four times etc... Make this function return the List of integers. */ -List DeckOfCards() { +List? DeckOfCards() { List Cards = []; List Deck = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]; List Suits = ["Spaði", "Tígul", "Hjarta", "Lauf"]; diff --git a/lib/functions/money_grab.dart b/lib/functions/money_grab.dart index b397dee..074e671 100644 --- a/lib/functions/money_grab.dart +++ b/lib/functions/money_grab.dart @@ -19,10 +19,10 @@ Can you design the function such that it will ask the user again if he doesn't input a integer? */ -int PlaceBet(int bankRoll) { +int? PlaceBet(int bankRoll) { } -int BuyIn() { +int? BuyIn() { } \ No newline at end of file diff --git a/lib/functions/option_select.dart b/lib/functions/option_select.dart index 981a9b9..9d0d92c 100644 --- a/lib/functions/option_select.dart +++ b/lib/functions/option_select.dart @@ -18,6 +18,6 @@ that the function will simply ask the user again to input an answer? */ -int OptionSelect(String statement, List options) { +int? OptionSelect(String statement, List options) { } \ No newline at end of file diff --git a/lib/functions/score_function.dart b/lib/functions/score_function.dart index 12e7e97..6ce848a 100644 --- a/lib/functions/score_function.dart +++ b/lib/functions/score_function.dart @@ -20,8 +20,23 @@ gets the score 1. So if the method gets the hand [1, 1] the score would be 12 hand = [11, 13] -> Score 20 hand = [7, 1] -> Score 18 */ +// firstAce = 13; +// followUpAce = 1; int CalculateScore(List hand){ - + int result = 0; + bool isAce = false; + hand.forEach((element) { + if (element > 10) { + element = 10; + } + if (element == 1 && isAce == false){ + element = 11; + isAce = true; + } else if(element == 1 && isAce == true) { + element = 1; + } + result += element; +}); + return result; } - diff --git a/lib/functions/shuffled_deck.dart b/lib/functions/shuffled_deck.dart index d100f4d..d1b3da3 100644 --- a/lib/functions/shuffled_deck.dart +++ b/lib/functions/shuffled_deck.dart @@ -8,6 +8,6 @@ Shuffler And when run, returns a shuffled deck of cards. No inputs, only output. */ -List ShuffledDeck(){ +List? ShuffledDeck(){ } \ No newline at end of file diff --git a/lib/functions/shuffler.dart b/lib/functions/shuffler.dart index 2e980ac..bdd91c7 100644 --- a/lib/functions/shuffler.dart +++ b/lib/functions/shuffler.dart @@ -7,6 +7,6 @@ and outputs a shuffled list of integers. I.e, it should return a RANDOMIZED version of the list. */ -List Shuffler(List theList){ +List? Shuffler(List theList){ } \ No newline at end of file diff --git a/lib/functions/status.dart b/lib/functions/status.dart index bf31751..38a57af 100644 --- a/lib/functions/status.dart +++ b/lib/functions/status.dart @@ -14,7 +14,7 @@ on what hand he has, his score and the hand of the house. hand before showdown.) */ -List CardNameList(List playerHand){ +List? CardNameList(List playerHand){ } diff --git a/pubspec.lock b/pubspec.lock index 2af4907..c98fc22 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -5,323 +5,369 @@ packages: dependency: transitive description: name: _fe_analyzer_shared - url: "https://pub.dartlang.org" + sha256: d976d24314f193899a3079b14fe336215a63a3b1e1c3743eabba8f83e049e9a9 + url: "https://pub.dev" source: hosted version: "49.0.0" analyzer: dependency: transitive description: name: analyzer - url: "https://pub.dartlang.org" + sha256: "40ba2c6d2ab41a66476f8f1f099da6be0795c1b47221f5e2c5f8ad6048cdffae" + url: "https://pub.dev" source: hosted version: "5.1.0" args: dependency: transitive description: name: args - url: "https://pub.dartlang.org" + sha256: b003c3098049a51720352d219b0bb5f219b60fbfb68e7a4748139a06a5676515 + url: "https://pub.dev" source: hosted version: "2.3.1" async: dependency: transitive description: name: async - url: "https://pub.dartlang.org" + sha256: "271b8899fc99f9df4f4ed419fa14e2fff392c7b2c162fbb87b222e2e963ddc73" + url: "https://pub.dev" source: hosted version: "2.9.0" boolean_selector: dependency: transitive description: name: boolean_selector - url: "https://pub.dartlang.org" + sha256: "5bbf32bc9e518d41ec49718e2931cd4527292c9b0c6d2dffcf7fe6b9a8a8cf72" + url: "https://pub.dev" source: hosted version: "2.1.0" collection: dependency: transitive description: name: collection - url: "https://pub.dartlang.org" + sha256: cfc915e6923fe5ce6e153b0723c753045de46de1b4d63771530504004a45fae0 + url: "https://pub.dev" source: hosted version: "1.17.0" convert: dependency: transitive description: name: convert - url: "https://pub.dartlang.org" + sha256: "0f08b14755d163f6e2134cb58222dd25ea2a2ee8a195e53983d57c075324d592" + url: "https://pub.dev" source: hosted version: "3.1.1" coverage: dependency: transitive description: name: coverage - url: "https://pub.dartlang.org" + sha256: d2494157c32b303f47dedee955b1479f2979c4ff66934eb7c0def44fd9e0267a + url: "https://pub.dev" source: hosted version: "1.6.1" crypto: dependency: transitive description: name: crypto - url: "https://pub.dartlang.org" + sha256: aa274aa7774f8964e4f4f38cc994db7b6158dd36e9187aaceaddc994b35c6c67 + url: "https://pub.dev" source: hosted version: "3.0.2" file: dependency: transitive description: name: file - url: "https://pub.dartlang.org" + sha256: "1b92bec4fc2a72f59a8e15af5f52cd441e4a7860b49499d69dfa817af20e925d" + url: "https://pub.dev" source: hosted version: "6.1.4" frontend_server_client: dependency: transitive description: name: frontend_server_client - url: "https://pub.dartlang.org" + sha256: "01fb90a581ee2bbca0a1c72b04f73b5e9e89b89bf608c9dfa815ea9cec00f11c" + url: "https://pub.dev" source: hosted version: "3.0.0" glob: dependency: transitive description: name: glob - url: "https://pub.dartlang.org" + sha256: c51b4fdfee4d281f49b8c957f1add91b815473597f76bcf07377987f66a55729 + url: "https://pub.dev" source: hosted version: "2.1.0" http_multi_server: dependency: transitive description: name: http_multi_server - url: "https://pub.dartlang.org" + sha256: "97486f20f9c2f7be8f514851703d0119c3596d14ea63227af6f7a481ef2b2f8b" + url: "https://pub.dev" source: hosted version: "3.2.1" http_parser: dependency: transitive description: name: http_parser - url: "https://pub.dartlang.org" + sha256: "2aa08ce0341cc9b354a498388e30986515406668dbcc4f7c950c3e715496693b" + url: "https://pub.dev" source: hosted version: "4.0.2" io: dependency: transitive description: name: io - url: "https://pub.dartlang.org" + sha256: "0d4c73c3653ab85bf696d51a9657604c900a370549196a91f33e4c39af760852" + url: "https://pub.dev" source: hosted version: "1.0.3" js: dependency: transitive description: name: js - url: "https://pub.dartlang.org" + sha256: a5e201311cb08bf3912ebbe9a2be096e182d703f881136ec1e81a2338a9e120d + url: "https://pub.dev" source: hosted version: "0.6.4" logging: dependency: transitive description: name: logging - url: "https://pub.dartlang.org" + sha256: c0bbfe94d46aedf9b8b3e695cf3bd48c8e14b35e3b2c639e0aa7755d589ba946 + url: "https://pub.dev" source: hosted version: "1.1.0" matcher: dependency: transitive description: name: matcher - url: "https://pub.dartlang.org" + sha256: "80c2989398773fa06e2457e9ff08580f24e9858b28462a722241cb53e5613478" + url: "https://pub.dev" source: hosted version: "0.12.12" meta: dependency: transitive description: name: meta - url: "https://pub.dartlang.org" + sha256: "6c268b42ed578a53088d834796959e4a1814b5e9e164f147f580a386e5decf42" + url: "https://pub.dev" source: hosted version: "1.8.0" mime: dependency: transitive description: name: mime - url: "https://pub.dartlang.org" + sha256: dab22e92b41aa1255ea90ddc4bc2feaf35544fd0728e209638cad041a6e3928a + url: "https://pub.dev" source: hosted version: "1.0.2" node_preamble: dependency: transitive description: name: node_preamble - url: "https://pub.dartlang.org" + sha256: "8ebdbaa3b96d5285d068f80772390d27c21e1fa10fb2df6627b1b9415043608d" + url: "https://pub.dev" source: hosted version: "2.0.1" package_config: dependency: transitive description: name: package_config - url: "https://pub.dartlang.org" + sha256: "1c5b77ccc91e4823a5af61ee74e6b972db1ef98c2ff5a18d3161c982a55448bd" + url: "https://pub.dev" source: hosted version: "2.1.0" path: dependency: transitive description: name: path - url: "https://pub.dartlang.org" + sha256: db9d4f58c908a4ba5953fcee2ae317c94889433e5024c27ce74a37f94267945b + url: "https://pub.dev" source: hosted version: "1.8.2" pedantic: dependency: "direct dev" description: name: pedantic - url: "https://pub.dartlang.org" + sha256: "67fc27ed9639506c856c840ccce7594d0bdcd91bc8d53d6e52359449a1d50602" + url: "https://pub.dev" source: hosted version: "1.11.1" pool: dependency: transitive description: name: pool - url: "https://pub.dartlang.org" + sha256: "20fe868b6314b322ea036ba325e6fc0711a22948856475e2c2b6306e8ab39c2a" + url: "https://pub.dev" source: hosted version: "1.5.1" pub_semver: dependency: transitive description: name: pub_semver - url: "https://pub.dartlang.org" + sha256: b959af0a045c3484c4a8f4997731f5bfe4cac60d732fd8ce35b351f2d6a459fe + url: "https://pub.dev" source: hosted version: "2.1.2" shelf: dependency: transitive description: name: shelf - url: "https://pub.dartlang.org" + sha256: c24a96135a2ccd62c64b69315a14adc5c3419df63b4d7c05832a346fdb73682c + url: "https://pub.dev" source: hosted version: "1.4.0" shelf_packages_handler: dependency: transitive description: name: shelf_packages_handler - url: "https://pub.dartlang.org" + sha256: aef74dc9195746a384843102142ab65b6a4735bb3beea791e63527b88cc83306 + url: "https://pub.dev" source: hosted version: "3.0.1" shelf_static: dependency: transitive description: name: shelf_static - url: "https://pub.dartlang.org" + sha256: e792b76b96a36d4a41b819da593aff4bdd413576b3ba6150df5d8d9996d2e74c + url: "https://pub.dev" source: hosted version: "1.1.1" shelf_web_socket: dependency: transitive description: name: shelf_web_socket - url: "https://pub.dartlang.org" + sha256: "6db16374bc3497d21aa0eebe674d3db9fdf82082aac0f04dc7b44e4af5b08afc" + url: "https://pub.dev" source: hosted version: "1.0.2" source_map_stack_trace: dependency: transitive description: name: source_map_stack_trace - url: "https://pub.dartlang.org" + sha256: "8c463326277f68a628abab20580047b419c2ff66756fd0affd451f73f9508c11" + url: "https://pub.dev" source: hosted version: "2.1.0" source_maps: dependency: transitive description: name: source_maps - url: "https://pub.dartlang.org" + sha256: "52de2200bb098de739794c82d09c41ac27b2e42fd7e23cce7b9c74bf653c7296" + url: "https://pub.dev" source: hosted version: "0.10.10" source_span: dependency: transitive description: name: source_span - url: "https://pub.dartlang.org" + sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250 + url: "https://pub.dev" source: hosted version: "1.9.1" stack_trace: dependency: transitive description: name: stack_trace - url: "https://pub.dartlang.org" + sha256: f8d9f247e2f9f90e32d1495ff32dac7e4ae34ffa7194c5ff8fcc0fd0e52df774 + url: "https://pub.dev" source: hosted version: "1.10.0" stream_channel: dependency: transitive description: name: stream_channel - url: "https://pub.dartlang.org" + sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8" + url: "https://pub.dev" source: hosted version: "2.1.1" string_scanner: dependency: transitive description: name: string_scanner - url: "https://pub.dartlang.org" + sha256: "862015c5db1f3f3c4ea3b94dc2490363a84262994b88902315ed74be1155612f" + url: "https://pub.dev" source: hosted version: "1.1.1" term_glyph: dependency: transitive description: name: term_glyph - url: "https://pub.dartlang.org" + sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 + url: "https://pub.dev" source: hosted version: "1.2.1" test: dependency: "direct dev" description: name: test - url: "https://pub.dartlang.org" + sha256: "9ffb8dbda445ba2922522423e7c7288967de89129205ce2dadf856abfd2b72ae" + url: "https://pub.dev" source: hosted version: "1.21.6" test_api: dependency: transitive description: name: test_api - url: "https://pub.dartlang.org" + sha256: ceeddf59d613e862e77f4b506cfc2945ac9637ce0b4c00f4f4c1ac639f3e9731 + url: "https://pub.dev" source: hosted version: "0.4.14" test_core: dependency: transitive description: name: test_core - url: "https://pub.dartlang.org" + sha256: "2b38b8ecfa37f8d375b4aa2a106a86ade536b577411530c2ea68c83abb1f004b" + url: "https://pub.dev" source: hosted version: "0.4.18" typed_data: dependency: transitive description: name: typed_data - url: "https://pub.dartlang.org" + sha256: "26f87ade979c47a150c9eaab93ccd2bebe70a27dc0b4b29517f2904f04eb11a5" + url: "https://pub.dev" source: hosted version: "1.3.1" vm_service: dependency: transitive description: name: vm_service - url: "https://pub.dartlang.org" + sha256: e7fb6c2282f7631712b69c19d1bff82f3767eea33a2321c14fa59ad67ea391c7 + url: "https://pub.dev" source: hosted version: "9.4.0" watcher: dependency: transitive description: name: watcher - url: "https://pub.dartlang.org" + sha256: "6a7f46926b01ce81bfc339da6a7f20afbe7733eff9846f6d6a5466aa4c6667c0" + url: "https://pub.dev" source: hosted version: "1.0.2" web_socket_channel: dependency: transitive description: name: web_socket_channel - url: "https://pub.dartlang.org" + sha256: "3a969ddcc204a3e34e863d204b29c0752716f78b6f9cc8235083208d268a4ccd" + url: "https://pub.dev" source: hosted version: "2.2.0" webkit_inspection_protocol: dependency: transitive description: name: webkit_inspection_protocol - url: "https://pub.dartlang.org" + sha256: "67d3a8b6c79e1987d19d848b0892e582dbb0c66c57cc1fef58a177dd2aa2823d" + url: "https://pub.dev" source: hosted version: "1.2.0" yaml: dependency: transitive description: name: yaml - url: "https://pub.dartlang.org" + sha256: "23812a9b125b48d4007117254bca50abb6c712352927eece9e155207b1db2370" + url: "https://pub.dev" source: hosted version: "3.1.1" sdks: - dart: ">=2.18.0 <3.0.0" + dart: ">=2.18.0 <4.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index 754dc36..865402b 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -4,7 +4,7 @@ description: A sample command-line application. # homepage: https://www.example.com environment: - sdk: '>=2.11.0 <3.0.0' + sdk: '>=2.12.0 <3.0.0' #dependencies: # path: ^1.7.0