-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathGet-JackPot.ps1
1158 lines (998 loc) · 44.6 KB
/
Get-JackPot.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<#PSScriptInfo
.VERSION 3.2.0
.GUID 0fd916fe-3a0d-48c4-a196-18ea085e071f
.AUTHOR Craig Dayton
.COMPANYNAME Example.com
.COPYRIGHT Absolute Zero
.TAGS
.LICENSEURI
.PROJECTURI https://github.com/cadayton/JackPot
.ICONURI
.EXTERNALMODULEDEPENDENCIES
.REQUIREDSCRIPTS
.EXTERNALSCRIPTDEPENDENCIES
.RELEASENOTES
#>
<#
.SYNOPSIS
Display the current Washington State lottery game results and optionally stores the
results in a local history file.
.DESCRIPTION
Displays Washington lottery game results by invoking a web request to
http://www.walottery.com/WinningNumbers and extracts the game results
onto the console and optionally saves the results locally.
Picks game winning numbers based on frequency of past winning numbers.
.PARAMETER game
Displays all the history results of a specified lottery game in the Out-Gridview.
When used in combination with the '-picker' option, will select a set numbers to
be played for the specified game.
.PARAMETER online
Displays the current lottery game results on the console.
.PARAMETER update
Displays the current lottery game results on the console and updates
the history file.
When used in combination with '-online' option, will compare the winning
numbers to the numbers selected using the '-picker' and report on the number
of matches.
.PARAMETER all
Displays all the history lottery game results in a Out-Gridview.
.PARAMETER picker
Used in combination with the 'game' option to pick a set of winning
numbers for a game based on frequency of past winning numbers.
If the '-all' option is used in combintion with the '-picker' option then
then all potential game numbers will be candidates for selection.
To restore the number selection process back to only selecting from
the most frequently used numbers for a game, the file, JackPot-HotNums.csv
must be deleted.
.PARAMETER picks
Displays the history of past games that have been played.
.PARAMETER count
Used in combination with the 'game' and 'picker' option to generate
a specified set of numbers. The default is 1.
.INPUTS
A history csv file named, JackPot-Results.csv
http://www.walottery.com/WinningNumbers
.OUTPUTS
A history csv file named, JackPot-Results.csv
.EXAMPLE
The ordering of the examples below is the typically workflow
when placing lottery game bets.
It is not necessary to actually purchase any game tickets, but one can
just play along as though a purchase was made.
I doubt this code is providing any increase in the odds of winning any
specific game.
It will though greatly reduce the time it takes to sort out any winning
matches from multiple tickets. Provided one is using this code to
select the game numbers.
.EXAMPLE
Get-JackPot
Executing without any parameters will launch a character based menu for
easy display, picking, and verification of lottery numbers.
Added this feature for my Dad who does one finger typing. After using
the menu for a short time I find it easier than typing command line
parameters.
.EXAMPLE
Get-JackPot -update
Queries the lottery web page and then extracts and displays the
current game results. The history file, JackPot-Result.csv is then
updated with new game results.
Routinely running this command build a local copy of all the lottery
games.
.EXAMPLE
Get-JackPot -update -picker -game PowerBall -count 2
Generates 2 sets winning numbers for the 'PowerBall' game
and places the bets into the file, JackPot-Picks.csv.
The numbers are randomly selected from the game entries in the
file, JackPot-HotNums.csv. This file consists of the most
frequently selected winning numbers for the game.
These numbers need to be generated on the same day as the
drawing is being held.
Get-JackPot -update -picker -all -game MegaMillions
The '-all' option sets the default selection of game numbers
to be all possible numbers for the game.
Delete the file, JackPot-HotNums.csv to restore the game selection
of numbers to the most frequently selected numbers for the game.
Example Output:
PowerBall Game (1): 16 23 25 32 64 09
PowerBall Game (2): 25 28 40 52 64 21
With these numbers in hand, go to your local lottery store
and complete the game card.
By default only the most frequent winning numbers for the game
are candidiates for selection. The default selection process
can be overridden by specified '-all' option.
Once the '-all' is specified that method becomes the new default.
To switch back to the prior default the file, JackPot-HotNums.csv
must be deleted.
Valid games are 'PowerBall', 'MegaMillions', 'Lotto', 'Hit5', 'Match4',
and 'DailyGame'.
.EXAMPLE
Get-JackPot -online -update
Queries the lottery web page and then extracts and displays the
current game results.
Next the winning results are compared to the picked numbers for the
game and a report is generated showing of balls matched per game.
The recent game picks in the file, JackPot-Picks.csv are updated
with the winning results and match count then moved to the file,
JackPot-PickHostory.csv. Afterwards, the JackPot-Picks.csv file is
removed.
.EXAMPLE
Get-JackPot
Displays the last 12 game history records on the console.
.EXAMPLE
Get-JackPot -game PowerBall
Displays all the PowerBall records in the history file.
.EXAMPLE
Get-JackPot -online
Queries the lottery web page and then extracts and displays the
current game results.
.EXAMPLE
Get-JackPot -picks
Displays history of the games played compared to the drawing results.
.NOTES
Author: Craig Dayton
3.2.0: 10/21/2017 - MegaMillion game ranges now (1-70) & MegaBall is (1-25)
3.1.0: 06/18/2017 - Improved Progress Bar displayed
3.0.0: 04/05/2017 - Implemented a character based menu interface
2.1.1: 04/01/2017 - Fixed logic errors & updated embeded documentation
2.1.0: 03/27/2017 - Added feature to evaluate picked numbers against winning numbers
2.0.0: 03/24/2017 - Added feature to generate a set of winning numbers
1.0.2: 03/24/2017 - Game record duplication algorthim modified
1.0.1: 03/23/2017 - Fixed some logic errors
1.0.0: 03/22/2017 - initial release.
.LINK
https://github.com/cadayton/JackPot
.LINK
http://jackpot.readthedocs.io
#>
# Using
using namespace System.Diagnostics
using namespace System.Management.Automation
#
# Get-JackPot Params
[cmdletbinding()]
Param(
[Parameter(Position=0,
Mandatory=$false,
HelpMessage = "Enter a lottery game name (i.e. PowerBall)",
ValueFromPipeline=$True)]
#[ValidateNotNullorEmpty("^[a-zA-Z]{12}$")]
[string]$game,
[Parameter(Position=1,
Mandatory=$false,
HelpMessage = "Display Online Lottery Results",
ValueFromPipeline=$True)]
[ValidateNotNullorEmpty()]
[switch]$online,
[Parameter(Position=2,
Mandatory=$false,
HelpMessage = "Display Online Lottery Results & update history file",
ValueFromPipeline=$True)]
[ValidateNotNullorEmpty()]
[switch]$update,
[Parameter(Position=3,
Mandatory=$false,
HelpMessage = "Display all game history file records",
ValueFromPipeline=$True)]
[ValidateNotNullorEmpty()]
[switch]$all,
[Parameter(Position=4,
Mandatory=$false,
HelpMessage = "Display all game history file records",
ValueFromPipeline=$True)]
[ValidateNotNullorEmpty()]
[switch]$picker,
[Parameter(Position=5,
Mandatory=$false,
HelpMessage = "Display the pick history of all games",
ValueFromPipeline=$True)]
[ValidateNotNullorEmpty()]
[switch]$picks,
[Parameter(Position=6,
Mandatory=$false,
HelpMessage = "Number of games",
ValueFromPipeline=$True)]
[ValidateNotNullorEmpty()]
[int]$count = 1
)
#
# Declarations
$URI1 = "http://www.walottery.com/WinningNumbers";
$vrsx = "3.2.0";
[String[]]$JackPotHeader = "Game", "DrawDate","DrawDay", "Numbers", "Multiplier", "JackPot", "NextDraw", "NextDay";
[String[]]$MultiHeader = "Game", "HotNums","Multiplier";
[String[]]$StdHeader = "Game", "HotNums";
[String[]]$DailyHeader = "Game", "Pos1","Pos2","Pos3";
[String[]]$PickHeader = "Game", "PickDate","PickDay","Choices","Cost","WinNums","Matches","Prize","Multiplier";
[String[]]$Picked = "Game", "PickDate","PickDay","Choices";
# Top frequent winning numbers per game
$HotArray = New-Object System.Collections.ArrayList;
$HotArray.Add('PowerBall,03 12 16 23 25 28 32 33 40 52 64 69,02 03 05 06 09 10 12 17 19 20 21 25') | Out-Null;
$HotArray.Add('MegaMillions,02 11 20 25 29 31 35 41 44 45 49 51,01 02 03 04 06 07 08 09 10 12 14 15') | Out-Null;
$HotArray.Add('Lotto,28 26 03 37 47 13 17 27 39 49 19 25 43 21 20 08 41 12 01 24 10') | Out-Null;
$HotArray.Add('Hit5,35 37 13 33 14 23 17 12 27 07 28 02 21 03 11 34 38 10 31') | Out-Null;
$HotArray.Add('Match4,19 18 24 05 13 08 04 02 16 07 21 06') | Out-Null;
$HotArray.Add('DailyGame,8 5 4 7 1,7 2 9 6 5,8 0 1 2 4') | Out-Null;
#
# All game numbers
$AllArray = New-Object System.Collections.ArrayList;
$AllArray.Add('PowerBall,01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69,01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26') | Out-Null;
$AllArray.Add('MegaMillions,01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70,01 02 03 04 06 07 08 09 10 12 14 15 16 17 18 19 20 21 22 23 24 25') | Out-Null;
$AllArray.Add('Lotto,01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49') | Out-Null;
$AllArray.Add('Hit5,01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39') | Out-Null;
$AllArray.Add('Match4,01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24') | Out-Null;
$AllArray.Add('DailyGame,1 2 3 4 5 6 7 8 9,1 2 3 4 5 6 7 8 9,1 2 3 4 5 6 7 8 9') | Out-Null;
#
#
# Classes
class ProgressManager {
[long] $TotalItemCount
hidden [int] $ActivityId
hidden [int] $ParentActivityId
hidden [string] $Activity
[string] $StatusDescription
hidden [StopWatch] $Stopwatch
[long] $currentItemIndex
ProgressManager([string] $activity, [string] $statusDescription, [long] $totalItemCount) {
$this.init($activity, $StatusDescription, $totalItemCount, 1, - 1)
}
ProgressManager([string] $activity, [string] $statusDescription, [long] $totalItemCount, [int] $activityId, [int] $parentActivityId) {
$this.init($activity, $StatusDescription, $totalItemCount, $activityId, $parentActivityId)
}
hidden init([string] $activity, [string] $statusDescription, [long] $totalItemCount, [int] $activityId, [int] $parentActivityId) {
$this.TotalItemCount = $totalItemCount
$this.StatusDescription = $statusDescription
$this.ActivityId = $activityId
$this.ParentActivityId = $parentActivityId
$this.Activity = $activity
$this.Stopwatch = [Stopwatch]::StartNew()
}
[ProgressRecord] GetCurrentProgressRecord([string] $currentOperation) {
$pr = [ProgressRecord]::new($this.ActivityId, $this.Activity, $this.StatusDescription)
$pr.CurrentOperation = $currentOperation
$pr.ParentActivityId = $this.ParentActivityId
$pr.PercentComplete = $this.GetPercentComplete($this.currentItemIndex)
$pr.SecondsRemaining = $this.GetSecondsRemaining($this.currentItemIndex)
$this.currentItemIndex++
return $pr
}
[ProgressRecord] GetCurrentProgressRecord([long] $currentItemIndex, [string] $currentOperation) {
$this.currentItemIndex = $currentItemIndex
return $this.GetCurrentProgressRecord($currentOperation)
}
[ProgressRecord] GetCompletedRecord() {
$pr = [ProgressRecord]::new($this.ActivityId, $this.Activity, $this.StatusDescription)
$pr.RecordType = [ProgressRecordType]::Completed
return $pr
}
hidden [int] GetSecondsRemaining([long] $currentItemIndex) {
if ($this.stopwatch.ElapsedMilliseconds -lt 3000) {return -1 }
if ($currentItemIndex -ge $this.totalItemCount) { return 0 }
return [int] (($this.totalItemCount - $currentItemIndex) * $this.stopwatch.Elapsed.TotalSeconds / $currentItemIndex)
}
hidden [int] GetPercentComplete([long] $currentItemIndex) {
if ($currentItemIndex -ge $this.totalItemCount) { return 100 }
return [Math]::Min([int] ($currentItemIndex * 100 / $this.totalItemCount), 100)
}
}
#
# Functions
function Convert-fileToCSV {
param ([string]$fname)
$bufLine = $null;
$game = $Global:game;
[bool]$needNums = $true;
$DrawDate, $DrawDay, $Numbers, $Multiplier, $Prize, $NextDate, $NextDay = $null;
get-content -Path $fname | ForEach-Object { # process each input line
# evaluate any non-blank line
if ($_ -notmatch "^ ") {
$curLine = $_;
if ($curLine -match "Latest Draw:" -and $DrawDate -eq $null) {
$junk,$ld = $curline.Split(":");
$day,$date = $ld.Split("/");
$DrawDay = $day;
$DrawDate = Get-Date $date -format yyyy-MM-dd;
}
if ($curLine -match "^\d" -and $needNums) {
$Numbers += $curLine + " ";
}
if ($curLine -match "Power Play" -and $Multiplier -eq $null) {
$Multiplier = $curLine.Substring(11,3);
}
if ($curLine -match "Megaplier" -and $Multiplier -eq $null) {
$Multiplier = $curLine.Substring(10,3);
}
if ($curLine -match "[$]" -and $Prize -eq $null) {
$needNums = $false;
$Prize = $curLine;
}
if ($curLine -match "Next Draw:" -and $NextDate -eq $null) {
$junk,$ld = $curline.Split(":");
$day,$date = $ld.Split("/");
if ($date -ne $null ) {
$NextDay = $day;
$NextDate = Get-Date $date -format yyyy-MM-dd;
} else {
$NextDate = $day;
};
}
if ($curLine -match "Daily" -and $NextDate -eq $null) { $NextDate = $curLine};
}
}
$bufLine = $game + ";" + $DrawDate + ";" + $DrawDay + ";" + $Numbers + ";";
$bufLine += $Multiplier + ";" + $Prize + ";" + $NextDate + ";" + $NextDay;
$bufLine | Out-File -FilePath $temp2 -Append -Encoding ascii;
if (Test-Path $fname) { Remove-Item -Path $fname };
}
function Update-JackPotHistory {
param ([string]$fname)
if (Test-Path $JackPot ) {
$histLine = Get-Content -Path $JackPot | Select-Object -Last 1;
$currLine = Get-Content -Path $fname | Select-Object -Last 1;
if ($histLine -ne $currLine) { # Update history file
$histLine = Get-Content -Path $JackPot | Select-Object -Last 12;
get-content -Path $fname | ForEach-Object { # process each input line
$curLine = $_;
$curLine24 = $_.Substring(0,23);
[bool]$duplicate = $false;
# Elimate duplcate entries in the history file
$histLine | ForEach-Object {
$histLine24 = $_.Substring(0,23);
if ($curLine24 -eq $histLine24) {
$duplicate = $true;
}
}
if ($duplicate) {} else {
$curLine | Out-File -FilePath $JackPot -Append -Encoding ascii;
}
}
}
} else {
get-content -Path $fname | ForEach-Object { # process each input line
$_ | Out-File -FilePath $JackPot -Append -Encoding ascii;
}
}
}
function Get-Matches {
param([string]$pickGame, [string]$choices, [string]$winners)
$c1 = $choices.Split(" ");
$w1 = $winners.Split(" ");
[int]$matchcnt = 0;
[int]$gameBall = 0;
[int]$lastIdx = $w1.Length - 1;
[int[]]$matchRslt = 0,0;
for ($i = 0;$i -le $lastIdx; $i++) {
for ($j = 0; $j -le $lastIdx; $j++) {
if ($c1[$i] -eq $w1[$j]) {
$matchcnt++
if ($pickGame -eq "PowerBall" -or $pickGame -eq "MegaMillions") {
if ($i -eq $lastIdx -and $j -eq $lastIdx) {$gameBall++; $matchcnt--; }
}
}
}
}
$matchRslt[0] = $matchcnt; $matchRslt[1] = $gameBall;
return $matchRslt;
}
function Update-PickHistory {
param ([string]$fname)
if (Test-Path $curPicks ) {
$currentGames = Import-CSV -Path $fname -Delimiter ";" -Header $JackPotHeader;
$currentPicks = Import-CSV -Path $curPicks -Delimiter ";" -Header $PickHeader;
$pickResults = @();
Write-Host "Checking prior games for matching numbers..." -ForegroundColor Yellow;
$currentGames | ForEach-Object {
[bool]$gameBallMatch = $false;
$curGame = $_;
$curGameName = $_.Game + $_.DrawDate;
#[int]$cmpSize = ($gameName.Length + 11) - 1;
#$curGameDate = $_DrawDate;
$currentPicks | ForEach-Object {
$curPick = $_;
$curPickName = $_.Game + $_.PickDate;
if ($curGameName -eq $curPickName) {
$curPick.WinNums = $curGame.Numbers;
if ($curPick.Choices -eq $curGame.Numbers) { # All numbers match!!
$nums = $curGame.Numbers;
$cnt = $nums.Split(" ")
$curPick.Matches = $cnt.Length;
$gameBallMatch = $true;
$color = "Red";
} else { # count matching numbers
$matches = Get-Matches $curPick.Game $curPick.Choices $curPick.WinNums;
$curPick.Matches = $matches[0];
if ($matches[0] -gt 0) { $color = "Green"} else { $color = "Blue"}
if ($matches[1] -gt 0) { $gameBallMatch = $true; $color1 = "Green"} else {$color1 = "Blue"}
}
if ($curPick.Game -eq "PowerBall" -or $curPick.Game -eq "MegaMillions" ) {
$curPick.Multiplier = $curGame.Multiplier;
} else {
$curPick.Multiplier = "NA";
};
$curPick | Export-CSV -Path $PickHis -Delimiter "," -Append -NoTypeInformation
$pickResults += $curPick;
}
}
}
$pickResults | Format-Table -Auto
Write-Host "Check $URI1 for the amount won for each match" -ForegroundColor Green
Remove-Item -Path $curPicks
}
}
function Get-WaWebRequest {
[long]$totalTasks = 7;
$pm = [ProgressManager]::new("Processing response from $URI1", "Getting Game Results", $totalTasks)
$PSCmdlet.WriteProgress( $pm.GetCurrentProgressRecord(1, "Executing Web Request"))
$response = Invoke-WebRequest -URI $URI1;
Start-Sleep -Seconds 3;
if ($response.StatusCode -eq "200") {
$Global:game = "PowerBall";
$PSCmdlet.WriteProgress( $pm.GetCurrentProgressRecord(2, "Processing $Global:game results 1 of 6"))
$data = $($response.ParsedHtml.getElementsByTagName("div") |
Where-Object classname -eq "game-bucket game-bucket-powerball"
);
$data.innerText | Out-File -FilePath $temp1 -Append -Encoding ascii;
Convert-fileToCSV $temp1;
$Global:game = "MegaMillions";
$PSCmdlet.WriteProgress( $pm.GetCurrentProgressRecord(3, "Processing $Global:game results 2 of 6"))
$data = $($response.ParsedHtml.getElementsByTagName("div") |
Where-Object classname -eq "game-bucket game-bucket-megamillions"
);
$data.innerText | Out-File -FilePath $temp1 -Append -Encoding ascii;
Convert-fileToCSV $temp1;
$Global:game = "Lotto";
$PSCmdlet.WriteProgress( $pm.GetCurrentProgressRecord(4, "Processing $Global:game results 3 of 6"))
$data = $($response.ParsedHtml.getElementsByTagName("div") |
Where-Object classname -eq "game-bucket game-bucket-lotto"
);
$data.innerText | Out-File -FilePath $temp1 -Append -Encoding ascii;
Convert-fileToCSV $temp1;
$Global:game = "Hit5";
$PSCmdlet.WriteProgress( $pm.GetCurrentProgressRecord(5, "Processing $Global:game results 4 of 6"))
$data = $($response.ParsedHtml.getElementsByTagName("div") |
Where-Object classname -eq "game-bucket game-bucket-hit5"
);
$data.innerText | Out-File -FilePath $temp1 -Append -Encoding ascii;
Convert-fileToCSV $temp1;
$Global:game = "Match4";
$PSCmdlet.WriteProgress( $pm.GetCurrentProgressRecord(6, "Processing $Global:game results 5 of 6"))
$data = $($response.ParsedHtml.getElementsByTagName("div") |
Where-Object classname -eq "game-bucket game-bucket-match4"
);
$data.innerText | Out-File -FilePath $temp1 -Append -Encoding ascii;
Convert-fileToCSV $temp1;
$Global:game = "DailyGame";
$PSCmdlet.WriteProgress( $pm.GetCurrentProgressRecord(7, "Processing $Global:game results 6 of 6"))
$data = $($response.ParsedHtml.getElementsByTagName("div") |
Where-Object classname -eq "game-bucket game-bucket-dailygame"
);
$data.innerText | Out-File -FilePath $temp1 -Append -Encoding ascii;
Convert-fileToCSV $temp1;
$PSCmdlet.WriteProgress($pm.GetCompletedRecord());
<# commented out Keno
$Global:game = "Keno"; $Global:ID = 7;
Write-Host " Processing $Global:game results" -ForegroundColor Green
$data = $($response.ParsedHtml.getElementsByTagName("div") |
Where-Object classname -eq "game-bucket game-bucket-keno"
);
$data.innerText | Out-File -FilePath $temp1 -Append -Encoding ascii;
Convert-fileToCSV $temp1;
#>
$currentGames = Import-CSV -Path $temp2 -Delimiter ";" -Header $JackPotHeader;
$currentGames | Format-Table -AutoSize -Wrap
if ($update) { Update-JackPotHistory $temp2; };
if ((Test-Path $curPicks) -and $online -and $update) { Update-PickHistory $temp2 };
if (Test-Path $temp2 ) {
Remove-Item -Path $temp2
};
if ($menu) {
Read-Host "Press any key to continue...";
}
} else {
Write-Host "Received error code: $response.StatusCode from $URI1";
}
}
function Show-JackPotError {
param ($fileNm)
Write-Host "$fileNm not found" -ForegroundColor Blue
switch ($fileNm) {
$JackPot {
Write-Host "Execute 'Get-JackPot -update' to create the history file."
Write-Host "Get-Help Get-JackPot -full and review the documentation."
Write-Host " "
}
$PickHis {
Write-Host "It is likely you've never selected option 4 from the Main Menu."
Write-Host "Once option 4 has been performed, the PickHistory file will be created."
Write-Host " "
}
Default { }
}
}
function Get-MultiPicker {
$HotPB = Import-CSV -Path $HotNums -Delimiter "," -Header $MultiHeader |
Where-Object {$_.Game -match $game };
for ($i = 1; $i -le $count; $i++) {
$topNums = $HotPB.HotNums;
$topMulti = $HotPB.Multiplier;
$top1 = $topNums.Split(" ");
$top2 = $topMulti.Split(" ");
$sel1 = Get-Random -InputObject $top1 -Count 5
$sel2 = Get-Random -InputObject $top2 -Count 1
$sela = $sel1 | Sort-Object;
$selb = [system.String]::Join(" ",$sela)
$sel = $selb + " " + $sel2;
if (!($menu)) {
Write-Host "$game Game ($i): $sel" -ForegroundColor Green
} elseif ($count -eq 1) {
$Global:sel = $sel;
}
if ($update) {
$dt = Get-Date -format "yyyy-MM-dd";
$da = Get-Date -uformat %a;
$da = " " + $da.ToUpper();
$grec = $game + ";" + $dt + ";" + $da + ";" + $sel + ";;;";
$grec | Out-File -FilePath $curPicks -Append -Encoding ascii;
}
}
}
function Get-NumPicker {
Param ([int]$numcnt)
$HotPB = Import-CSV -Path $HotNums -Delimiter "," -Header $StdHeader |
Where-Object {$_.Game -match $game };
for ($i = 1; $i -le $count; $i++) {
$topNums = $HotPB.HotNums;
$top1 = $topNums.Split(" ");
$sel1 = Get-Random -InputObject $top1 -Count $numcnt
$sela = $sel1 | Sort-Object;
$selb = [system.String]::Join(" ",$sela)
if (!($menu)) {
Write-Host "$game Game ($i): $selb" -ForegroundColor Green
} elseif ($count -eq 1) {
$Global:sel = $selb;
}
if ($update) {
$dt = Get-Date -format "yyyy-MM-dd";
$da = Get-Date -uformat %a;
$da = " " + $da.ToUpper();
$grec = $game + ";" + $dt + ";" + $da + ";" + $selb + ";;;";
$grec | Out-File -FilePath $curPicks -Append -Encoding ascii;
}
}
}
function Get-GameNumbers {
if ($all) {
if (Test-Path $HotNums) { Remove-Item -Path $HotNums }
$AllArray | ForEach-Object {
$_ | Out-File -FilePath $HotNums -Append -Encoding ascii;
}
}
if (Test-Path $HotNums) {} else {
# Create the file dynamically
$HotArray | ForEach-Object {
$_ | Out-File -FilePath $HotNums -Append -Encoding ascii;
}
}
switch ($game) {
"PowerBall" {
Get-MultiPicker;
}
"MegaMillions" {
Get-MultiPicker;
}
"Lotto" {
Get-NumPicker 6
}
"Hit5" {
Get-NumPicker 5
}
"Match4" {
Get-NumPicker 4
}
"DailyGame" {
$HotPB = Import-CSV -Path $HotNums -Delimiter "," -Header $DailyHeader |
Where-Object {$_.Game -match $game };
for ($i = 1; $i -le $count; $i++) {
$topPos1 = $HotPB.Pos1;
$topPos2 = $HotPB.Pos2;
$topPos3 = $HotPB.Pos3;
$pos1 = $topPos1.Split(" ");
$pos2 = $topPos2.Split(" ");
$pos3 = $topPos3.Split(" ");
$sel1 = Get-Random -InputObject $pos1 -Count 1
$sel2 = Get-Random -InputObject $pos2 -Count 1
$sel3 = Get-Random -InputObject $pos3 -Count 1
$sel = $sel1 + " " + $sel2 + " " + $sel3;
Write-Host "$game Game ($i): $sel" -ForegroundColor Green
if ($update) {
$dt = Get-Date -format "yyyy-MM-dd";
$da = Get-Date -uformat %a;
$da = " " + $da.ToUpper();
$grec = $game + ";" +$dt + ";" + $da + ";" + $sel + ";;;";
$grec | Out-File -FilePath $curPicks -Append -Encoding ascii;
}
}
}
Default {
Write-Host "$game not found" -ForegroundColor Red
Write-Host "Valid game names are: 'PowerBall, MegaMillions, Hit5, Match4, and DailyGame' " -ForegroundColor Green
}
}
}
#
# Menu Functions
function Get-GameCount {
param ([string]$game1)
[int]$cntGames = Read-Host "Number of $game1 games to play? ([1]-5)";
if ($cntGames -ge 1 -and $cntGames -le 5) {
return $cntGames
} else {return 1}
}
function clear-line1 {
$curPos = $host.UI.RawUI.CursorPosition
$curPos.X = 2; $curPos.Y = 1;
$host.UI.RawUI.CursorPosition = $curPos
$stline = "."
$stline = $stline.PadLeft(68)
Write-Host $stline -NoNewline -ForegroundColor Black
}
function clear-screen {
$stline = "."
$stline = $stline.PadLeft(90)
for($i=0; $i -le 23; $i++){
$curPos = $host.UI.RawUI.CursorPosition
$curPos.X = 0; $curPos.Y = $i;
$host.UI.RawUI.CursorPosition = $curPos
Write-Host $stline -ForegroundColor Black
}
}
function Get-DonateMenu {
Param ($menucolor = "Blue", $promptcolor = "Green", $pickColor = "White")
$DonateResp = "."
$DonateResp = $gameResp.PadLeft(68)
$online = $true; $update=$true;
$da = Get-Date -uformat %a
Do {
Clear-Host
Write-Host " "
Write-Host " $DonateResp " -ForegroundColor Red
Write-Host " =====================================================" -ForegroundColor $menucolor
Write-Host " | Select Donation Method |" -ForegroundColor $menucolor
Write-Host " =====================================================" -ForegroundColor $menucolor
Write-Host " | |" -ForegroundColor $menucolor
Write-Host " | 1. PayPal Donation |" -ForegroundColor $pickColor
Write-Host " | |" -ForegroundColor $menucolor
Write-Host " | 2. BitCoin Donation (BTC) |" -ForegroundColor $pickColor
Write-Host " | |" -ForegroundColor $menucolor
Write-Host " | 3. BitCoin Cash Donation (BTH) |" -ForegroundColor $pickColor
Write-Host " | |" -ForegroundColor $menucolor
Write-Host " | 4. Etherum Donation (ETH) |" -ForegroundColor $pickColor
Write-Host " | |" -ForegroundColor $menucolor
Write-Host " | 5. LiteCoin Donation (LTC) |" -ForegroundColor $pickColor
Write-Host " | |" -ForegroundColor $menucolor
Write-Host " | 6. Exit |" -ForegroundColor Magenta
Write-Host " | |" -ForegroundColor $menucolor
Write-Host " =====================================================" -ForegroundColor $menucolor
Write-Host " "
Write-Host " Select a Donation Method (1-5): " -ForegroundColor $promptcolor -NoNewline
$curPos = $host.UI.RawUI.CursorPosition
$curPos.X = 0
$host.UI.RawUI.CursorPosition = $curPos
Write-Host " Select a Donation Method (1-5): " -ForegroundColor $promptcolor -NoNewline
$DonateResp = " "
$DonateChoice = Read-Host
switch ($DonateChoice) {
1 { # PayPal Donation
$DonateResp = "THANK YOU!! for the PayPal Donation";
$URL = "https://www.paypal.me/CraigDayton";
# Edge Browser only
#$Browser = new-object -com internetexplorer.application;
#$Browser.navigate2($URL);
#$Browser.visible = $true;
#
# Default browser
"Donor" | Out-File -FilePath $temp3 -Append -Encoding ascii;
Start-Process $URL
$DonateResp = $DonateResp.PadRight(68);break
}
2 { # BitCoin Donation
$DonateResp = "THANK YOU!! for the BitCoin (BTC) Donation to: 12YvJdkuFarTLqeaomPCXxBW9xEXd88m6K";
"Donor" | Out-File -FilePath $temp3 -Append -Encoding ascii;
$DonateResp = $DonateResp.PadRight(68);break
}
3 { # BitCoin Cash Donation
$DonateResp = "THANK YOU!! for the BitCoin Cash (BTH) Donation to: 1At8tpGDVXp1uXQD11RRrQt7PtFwj1bhfN";
"Donor" | Out-File -FilePath $temp3 -Append -Encoding ascii;
$DonateResp = $DonateResp.PadRight(68);break
}
4 { # Ethernum Donation
$DonateResp = "THANK YOU!! for the Etherum (ETH) Donation to: 0xde9ab3188E485D77c45a925Fe4F7c7a8Bfc1D647";
"Donor" | Out-File -FilePath $temp3 -Append -Encoding ascii;
$DonateResp = $DonateResp.PadRight(68);break
}
5 { # LiteCoin Donation
$DonateResp = "THANK YOU!! for the LiteCoin (LTC) Donation to: LMumQYvevWqxi7Zr4cvZMf7NjgM6bX62CC";
"Donor" | Out-File -FilePath $temp3 -Append -Encoding ascii;
$DonateResp = $DonateResp.PadRight(68);break
}
6 { clear-line1; break }
default {
$DonateResp = "Invalid Choice.......Enter a value of 1-6 only"
$DonateResp = $DonateResp.PadRight(68)
}
}
} While ($DonateChoice -ne 6)
Clear-Screen
}
function Get-GameMenu {
Param ($menucolor = "Blue", $promptcolor = "Green", $pickColor = "White")
$gameResp = "."
$gameResp = $gameResp.PadLeft(68)
$online = $true; $update=$true;
$da = Get-Date -uformat %a
Do {
Clear-Host
Write-Host " "
Write-Host " $gameResp " -ForegroundColor Red
Write-Host " =====================================================" -ForegroundColor $menucolor
Write-Host " | Select Game to Play |" -ForegroundColor $menucolor
Write-Host " =====================================================" -ForegroundColor $menucolor
Write-Host " | |" -ForegroundColor $menucolor
Write-Host " | 1. Pick PowerBall Numbers (Wed,Sat) |" -ForegroundColor $pickColor
Write-Host " | |" -ForegroundColor $menucolor
Write-Host " | 2. Pick MegaMillions Numbers (Tue,Fri) |" -ForegroundColor $pickColor
Write-Host " | |" -ForegroundColor $menucolor
Write-Host " | 3. Pick Lotto Numbers (Mon,Wed,Sat) |" -ForegroundColor $pickColor
Write-Host " | |" -ForegroundColor $menucolor
Write-Host " | 4. Pick Hit5 Numbers (Mon,Wed,Sat) |" -ForegroundColor $pickColor
Write-Host " | |" -ForegroundColor $menucolor
Write-Host " | 5. Pick Match4 Numbers (Daily) |" -ForegroundColor $pickColor
Write-Host " | |" -ForegroundColor $menucolor
Write-Host " | 6. Pick DailyGame Numbers (Daily) |" -ForegroundColor $pickColor
Write-Host " | |" -ForegroundColor $menucolor
Write-Host " | 7. Show Game picks |" -ForegroundColor $pickColor
Write-Host " | |" -ForegroundColor $menucolor
Write-Host " | 8. Exit |" -ForegroundColor Magenta
Write-Host " | |" -ForegroundColor $menucolor
Write-Host " =====================================================" -ForegroundColor $menucolor
Write-Host " "
Write-Host " Select an option (1-8): " -ForegroundColor $promptcolor -NoNewline
$curPos = $host.UI.RawUI.CursorPosition
$curPos.X = 0
$host.UI.RawUI.CursorPosition = $curPos
Write-Host " Select an option (1-8): " -ForegroundColor $promptcolor -NoNewline
$gameResp = " "
$gameChoice = Read-Host
switch ($gameChoice) {
1 { $game = "PowerBall";
if ($da -eq "Wed" -or $da -eq "Sat") {
$count = Get-GameCount $game;
Get-GameNumbers;
if ($count -ne 1) {
$gameResp = "$count Number sets created for $game"
} else { $gameResp = "$Global:sel selected for $game"}
} else {
$gameResp = "$game is only played on Wed or Sat"
}
$gameResp = $gameResp.PadRight(68);break
}
2 { $game = "MegaMillions";
if ($da -eq "Tue" -or $da -eq "Fri") {
$count = Get-GameCount $game;
Get-GameNumbers;
if ($count -ne 1) {
$gameResp = "$count Number sets created for $game"
} else { $gameResp = "$Global:sel selected for $game"}
} else {
$gameResp = "$game is only played on Tue or Fri"
}
$gameResp = $gameResp.PadRight(68);break
}
3 { $game = "Lotto";
if ($da -eq "Mon" -or $da -eq "Wed" -or $da -eq "Sat") {
$count = Get-GameCount $game;
$count = $count * 2;
Get-GameNumbers;
if ($count -ne 1) {
$gameResp = "$count Number sets created for $game"
} else { $gameResp = "$Global:sel selected for $game"}
} else {
$gameResp = "$game is only played on Mon, Wed and Sat"
}
$gameResp = $gameResp.PadRight(68);break
}
4 { $game = "Hit5";
if ($da -eq "Mon" -or $da -eq "Wed" -or $da -eq "Sat") {
$count = Get-GameCount $game;
Get-GameNumbers;
if ($count -ne 1) {
$gameResp = "$count Number sets created for $game"
} else { $gameResp = "$Global:sel selected for $game"}
} else {
$gameResp = "$game is only played on Mon, Wed and Sat"
}
$gameResp = $gameResp.PadRight(68);break
}
5 { $game = "Match4";
$count = Get-GameCount $game;
Get-GameNumbers;
$gameResp = "$count Number sets created for $game";
$gameResp = $gameResp.PadRight(68);break
}
6 { $game = "DailyGame";
$count = Get-GameCount $game;
Get-GameNumbers;
if ($count -ne 1) {
$gameResp = "$count Number sets created for $game"
} else { $gameResp = "$Global:sel selected for $game"}
$gameResp = $gameResp.PadRight(68);break
}
7 { # List current Games
Clear-Host;
if (Test-Path $curPicks) {
$currentPicks = Import-CSV -Path $curPicks -Delimiter ";" -Header $Picked;
$currentPicks | Format-Table -AutoSize;
} else {
$gameResp = "No Games have be played yet"
$gameResp = $gameResp.PadRight(68);break
}
Read-Host "Press any key to continue..."
break;
}
8 { clear-line1; break }
default {
$gameResp = "Invalid Choice.......Try 1-8 only"
$gameResp = $gameResp.PadRight(68)
}
}
} While ($gameChoice -ne 8)
Clear-Screen
}
Function Get-MainMenu {
Param ($menucolor = "Blue", $promptcolor = "Green", $pickColor = "White")
Do {
Clear-Screen;
Clear-Host;
Write-Host ""