-
-
Save MattUV/5e96291a75208b3a943e27988b0a23da 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
extends Node | |
enum {J1_M, J1_A, J2_M, J2_A} | |
enum {MATIN, APREM} | |
enum {PVL, SOL, ALOC, LOC, ADEP, DEP, ITM, INI, COO, SQR, CS, CDT} | |
enum {H6, H7, H8, H9, H10, H11, H12, H13, H14, H15, H16, H17, H18} | |
const VIGIE = [PVL, SOL, ALOC, LOC] | |
const IFR = [ADEP, DEP, ITM, INI, COO, SQR, CS] | |
const ICONE_PC_6H := "res://icones/pc6h.png" | |
const ICONE_PC_7H := "res://icones/pc7h.png" | |
const ICONE_PC_10H := "res://icones/pc10h.png" | |
const ICONE_PC_11H := "res://icones/pc11h.png" | |
const ICONE_CDT_6H := "res://icones/cdt6h.png" | |
const ICONE_CDT_7H := "res://icones/cdt7h.png" | |
const ICONE_CDT_10H := "res://icones/cdt10h.png" | |
const ICONE_CDT_11H := "res://icones/cdt11h.png" | |
var controleur_list := [] | |
var team_j1 := 6 | |
var team_j2 := 5 | |
var controleurs_6h := ["DPY", "AMT", "DIA", "SUD", "GXA"] | |
var controleurs_7h := ["CIA", "POT", "BBN", "DJG", "RZE", "HUV", "JDH"]#, "LAG", "CVP"] | |
var cdt_6h := "DPY" | |
var cdt_7h := "CIA" | |
var controleurs_10h := ["JVT", "TRP", "GEY", "BLR", "RAE"] | |
var controleurs_11h := ["PHD", "KNO", "MHT", "DEL", "CML", "LAG", "DRT"] | |
var cdt_10h := "JVT" | |
var cdt_11h := "PHD" | |
func _ready(): | |
ajouter_controleur("CIA", 6, 4, CDT, COO) | |
ajouter_controleur("CVP", 6, 2, CDT, COO) | |
ajouter_controleur("COR", 6, 5, CDT, COO) | |
ajouter_controleur("DPY", 6, 3, CDT, COO) | |
ajouter_controleur("AMT", 6, 1, CS, COO) | |
ajouter_controleur("PAT", 6, 4, CS, COO) | |
ajouter_controleur("FRR", 6, 5, CS, COO) | |
ajouter_controleur("DIA", 6, 4, CS, COO) | |
ajouter_controleur("RZE", 6, 2, CS, COO) | |
ajouter_controleur("LAG", 6, 6, CS, COO) | |
ajouter_controleur("JUN", 6, 2, CS, COO) | |
ajouter_controleur("HUV", 6, 1, CS, COO) | |
ajouter_controleur("GXA", 6, 3, CS, COO) | |
ajouter_controleur("JRY", 6, 7, COO, LOC) | |
ajouter_controleur("BBN", 6, 0, DEP, LOC, [ITM, INI, COO]) | |
ajouter_controleur("POT", 6, 0, LOC, PVL, [ADEP, DEP, ITM, INI, COO]) | |
ajouter_controleur("JVT", 5, 4, CDT, COO) | |
ajouter_controleur("PHD", 5, 2, CDT, COO) | |
ajouter_controleur("KNO", 5, 5, CDT, COO) | |
ajouter_controleur("DGR", 5, 3, CDT, COO) | |
ajouter_controleur("ROP", 5, 1, CS, COO) | |
ajouter_controleur("TRP", 5, 4, CS, COO) | |
ajouter_controleur("MHT", 5, 5, CS, COO) | |
ajouter_controleur("CFT", 5, 4, CS, COO) | |
ajouter_controleur("GEY", 5, 2, CS, COO) | |
ajouter_controleur("DEL", 5, 6, CS, COO) | |
ajouter_controleur("CML", 5, 2, CS, COO) | |
ajouter_controleur("ADR", 5, 1, CS, COO) | |
ajouter_controleur("FRT", 5, 3, CS, COO) | |
ajouter_controleur("DRT", 5, 7, COO, LOC) | |
ajouter_controleur("BLR", 5, 0, DEP, LOC, [ITM, INI, COO]) | |
ajouter_controleur("RAE", 5, 0, LOC, PVL, [ADEP, DEP, ITM, INI, COO]) | |
ajouter_controleur("SUD", 1, 2, CS, COO) | |
ajouter_controleur("JDH", 7, 3, CS, COO) | |
ajouter_controleur("DJG", 7, 0, SOL, -1, [ALOC, LOC]) | |
func ajouter_controleur(trigramme : String, team : int, demi_journee : int, qualif_max : int, instructeur_max : int, en_instruction := []) -> void: | |
var controleur_dict := { | |
trigramme = trigramme, | |
team = team, | |
demi_journee = demi_journee, | |
qualif_max = qualif_max, | |
instructeur_max = instructeur_max, | |
en_instruction = en_instruction | |
} | |
controleur_list.append(controleur_dict) | |
func get_controleur(trigramme : String) -> Dictionary: | |
var controleur_dict : Dictionary | |
for c in controleur_list: | |
if c.trigramme == trigramme: | |
controleur_dict = c | |
break | |
return controleur_dict | |
func sort_controleurs(list : Array, key : String, subkey := "", invert := false) -> Array: | |
# Trie une liste de contrôleurs selon key, puis subkey | |
# La liste peut contenir des dictionnaires type controleur OU des trigrammes | |
# invert permet d'inverser le tri | |
var sorted := [] | |
if list.size() == 0: | |
return list | |
# Si la liste contient des trigrammes -> transforme en dictionnaires de contoleurs | |
var from_string = false | |
if list[0] is String: | |
from_string = true | |
for i in list.size(): | |
list[i] = get_controleur(list[i]) | |
# Création d'une Array temporaire contenant : | |
# [[Trigramme, value, subvalue, invert], [Trigramme, value, subvalue, invert], ... ] | |
# Si subkey n'est pas renseignée, un nombre au hasard est généré | |
var temp := [] | |
for c in list: | |
var trigramme : String = c.trigramme | |
var value = c[key] | |
var subvalue = randf() if subkey == "" else c[subkey] | |
temp.append([trigramme, value, subvalue,invert]) | |
# Tri de temp | |
temp.sort_custom(self, "_sort_by_values") | |
# Remplissage de sorted selon l'ordre de temp | |
for t in temp: | |
for c in list: | |
if c.trigramme == t[0]: | |
sorted.append(c) | |
break | |
# Si la liste contenait des trigrammes -> retransforme les dictionnaires en trigrammes | |
if from_string: | |
for i in sorted.size(): | |
sorted[i] = sorted[i].trigramme | |
return sorted | |
func _sort_by_values(a : Array, b: Array) -> bool: | |
# a = [trigramme_a, value_a, subvalue_a, invert] | |
# b = [trigramme_b, value_b, subvalue_b, invert] | |
# tri par value puis subvalue si les 2 values sont égales | |
# si invert == true -> inverse les values mais pas les subvalues | |
var invert : bool = a[3] | |
if a[1] < b[1]: | |
return true if !invert else false | |
elif a[1] == b[1]: | |
if a[2] < b[2]: | |
return true | |
else: | |
return false | |
else: | |
return false if !invert else true | |
func get_vac_icon(trigramme) -> Texture: | |
var vac_icon : Texture | |
if trigramme in controleurs_6h: | |
vac_icon = preload(ICONE_PC_6H) | |
elif trigramme in controleurs_7h: | |
vac_icon = preload(ICONE_PC_7H) | |
elif trigramme in controleurs_10h: | |
vac_icon = preload(ICONE_PC_10H) | |
elif trigramme in controleurs_11h: | |
vac_icon = preload(ICONE_PC_11H) | |
if trigramme == cdt_6h: | |
vac_icon = preload(ICONE_CDT_6H) | |
elif trigramme == cdt_7h: | |
vac_icon = preload(ICONE_CDT_7H) | |
elif trigramme == cdt_10h: | |
vac_icon = preload(ICONE_CDT_10H) | |
elif trigramme == cdt_11h: | |
vac_icon = preload(ICONE_CDT_11H) | |
return vac_icon | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment