-
Notifications
You must be signed in to change notification settings - Fork 0
/
DailyBattles.cs
96 lines (83 loc) · 2.82 KB
/
DailyBattles.cs
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
/**
* This file holds the main portion if the DaliyBattles system.
* More methods are to be added. Please check for updates regarding this file.
* Also if you want to send tips regarding CnCNet, This file or other files in this repository, I would greatly appreciate it.
*
* -SteamsDev
*/
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Resources;
using Rampastring.Tools;
namespace DailyBattles
{
public class DailyBattles
{
private string[] currentDate;
private string[] startDate;
private IniFile IniDailyBattles;
// Constructor for the class file
public DailyBattles()
{
currentDate = getCurrentDate();
startDate = getStartDate();
IniDailyBattles = new IniFile("DailyBattles.ini");
}
// This is for debugging purposes only. This uses the Microsoft VS Debugger.
private void DebugMode()
{
if (IniDailyBattles.GetStringValue("DebugMode", "Enabled", "false") == "true")
{
Console.WriteLine("DEBUG MODE ENABLED! Will output debug information to logfile.");
Debugger.Launch();
if (Debugger.IsLogging() == true)
Console.WriteLine("Debugger Launch Successful.");
else
throw new Exception ("Debugger failed to launch; Check to make sure the debugger is enabled and it can be attached to the program, and that is outputting information to logfile.");
}
}
// Ends Debug Mode.
private void EndDebugMode()
{
if (Debugger.IsLogging())
Debugger.Break();
}
// Check if the INI value for the implementation of Daily Battles is set to "true"
public bool dailyGameCheck => IniDailyBattles.GetStringValue("DailyBattles", "Enabled", "false") == "false";
// Check to see if the daily battle is played.
public bool IsPlayed()
{
int j = 0;
for (int i = 0; i < startDate.Length; ++i)
if (currentDate[i] == startDate[i])
++j;
return (j == 3);
}
// Get the current date using DateTime.
public string[] getCurrentDate()
{
int day = DateTime.Today.Day;
int month = DateTime.Today.Month;
int year = DateTime.Today.Year;
string[] currentDate = { day.ToString(), month.ToString(), year.ToString() };
return currentDate;
}
// Get the start date from the INI file.
public string[] getStartDate()
{
string currentStartDate = IniDailyBattles.GetStringValue("startDate", "1", "XX-XX-XXXX");
string[] startDate = currentStartDate.Split('-');
return startDate;
}
// Replacee the new start date with that of the current date.
public string[] newStartDate()
{
int[] newDate = { DateTime.Today.Day, DateTime.Today.Month, DateTime.Today.Year };
for (int i = 0; i < newDate.Length; ++i)
startDate[i] = newDate[i].ToString();
return startDate;
}
}
}