Created
February 3, 2014 05:22
-
-
Save meyea/8779208 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using PortableLeagueAPI; | |
using System.Collections.Generic; | |
using System.ComponentModel; | |
using System.Data; | |
using System.Drawing; | |
using System.Linq; | |
using System.Reflection; | |
using System.Text; | |
using System.Threading.Tasks; | |
using System.Windows.Forms; | |
//Known errors: Riot's API is unstable in the new season. If it returns an error (ex. 404) the program will try to ignore the returned error, but it can fail the error check. | |
namespace lolCompare_vform_ //Main namespace. No inheritance required. | |
{ | |
public partial class formSummoners : Form | |
{ | |
//var decs | |
static string summoner1Name; //Need to convert to Summoner ID | |
static string summoner2Name; //Need to convert to Summoner ID | |
static int summoner1ID; //converted int | |
static int summoner2ID; //converted int | |
static int? summoner1Tier; | |
static int? summoner2Tier; | |
static long ID11; | |
static long ID22; | |
static bool sum1done; | |
static bool sum2done; | |
static string sum1tierstring; | |
// end of var decs | |
public formSummoners() //initialize forms component | |
{ | |
InitializeComponent(); | |
} | |
private void Form1_Load(object sender, EventArgs e) //Function for when the program starts | |
{ | |
} | |
private void fightClick(object sender, EventArgs e) //Start the comparison on "FIGHT" click | |
{ | |
S2ID.summonertoID(); | |
Calculations.GetHighestTier1(ID11); | |
//Calculations.Compare(); | |
} | |
private void summ1Entered(object sender, EventArgs e) //Text in summ1Text Changed | |
{ | |
summoner1Name = (summ1Text.Text); | |
} | |
private void summ2Entered(object sender, EventArgs e) //Text in summ2Text Changed | |
{ | |
summoner2Name = (summ2Text.Text); | |
} | |
// non-user generated functions | |
public class S2ID | |
{ | |
public static void summonertoID() | |
{ | |
var ID1 = EF.RiotApi.Client.RiotWeb.API.Summoner.GetSummoner(summoner1Name); | |
ID11 = ID1.Id; | |
summoner1ID = unchecked((int)ID1.Id); | |
var ID2 = EF.RiotApi.Client.RiotWeb.API.Summoner.GetSummoner(summoner2Name); | |
ID22 = ID2.Id; | |
summoner2ID = unchecked((int)ID2.Id); | |
} | |
} | |
public class Calculations | |
{ | |
public static int GetHighestTier1 (long summonerid) | |
{ | |
var leagues = EF.RiotApi.Client.API.LeagueApi.Instance.GetLeagueBySummonerAsync(summonerid).Result; | |
int summoner1Tier = -1; | |
foreach (var league in leagues) | |
{ | |
var summoner1LeagueVar = league.Value; | |
if (summoner1LeagueVar.Tier.Contains("BRONZE")) | |
{ | |
summoner1Tier = 1; | |
} | |
else if (summoner1LeagueVar.Tier.Contains("SILVER")) | |
{ | |
summoner1Tier = 2; | |
} | |
else if (summoner1LeagueVar.Tier.Contains("GOLD")) | |
{ | |
summoner1Tier = 3; | |
} | |
else if (summoner1LeagueVar.Tier.Contains("PLATINUM")) | |
{ | |
summoner1Tier = 4; | |
} | |
else if (summoner1LeagueVar.Tier.Contains("DIAMOND")) | |
{ | |
summoner1Tier = 5; | |
} | |
else if (summoner1LeagueVar.Tier.Contains("CHALLENGER")) | |
{ | |
summoner1Tier = 6; | |
} | |
} | |
return summoner1Tier; | |
} | |
public static void Compare()// | |
{ | |
if(summoner1Tier > summoner2Tier) | |
{ | |
MessageBox.Show(summoner1Name, " wins"); | |
} | |
else | |
{ | |
MessageBox.Show(summoner2Name, " wins"); | |
} | |
} | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment