Auteur Sujet: Synopsys: Usage des bases for Miniville  (Lu 9139 fois)

0 Membres et 1 Invité sur ce sujet

Hors ligne Arenas

  • Newbie
  • *
  • Messages: 17
  • Karma : 2
    • Voir le profil
    • http://arenas.pagesperso-orange.fr/GradientExample/france-countdown.html
Synopsys: Usage des bases for Miniville
« le: avril 05, 2023, 20:54:33 pm »
# The stuff



cls

########################
#
# Synopsys:
#
# Creat
# 2023-02-10 00:33:07Z
# Modif
# 2023-02-25 10:25:47Z (last, ter)
#
# Copyright @renas alias (athome)
# France
#
# File Name :
# DownloadString-from-Mv-bases.ps1
#
# Us any Powershell version
# All Info are cumule
# Non restriction
#
# The convention is:
# 1 klick env for 2 pop
# 1 klick ind or *com for 3 pop
# 1 klick sec for 4 pop
# 1 klick tra for 5 pop
#
# * "com" is obsolete "Yстаревший, nicht verwenden, not tu use!
#
# Bases: pop/- us [math]::round(bases 1..4) = somme
#
# That's all to do. Great to hear from you.
#
########################

$Xt = [string] "#text"

# Type your Miniville city name

$Xminiville = "aldana" # aldana, mv0, xenia, burschi
$XmlUrl = "http://$Xminiville.miniville.fr/xml"
[xml]$Xml = (new-object System.Net.WebClient).DownloadString($XmlUrl)

$Xpop = $Xml.selectSingleNode('city/population').$Xt
$Xcom = $Xml.selectSingleNode('city/bases/@com').$Xt
$Xenv = $Xml.selectSingleNode('city/bases/@env').$Xt
$Xind = $Xml.selectSingleNode('city/bases/@ind').$Xt
$Xsec = $Xml.selectSingleNode('city/bases/@sec').$Xt
$Xtra = $Xml.selectSingleNode('city/bases/@tra').$Xt
""
""" Last update Date/Time (yyyy-mm-dd hh:mm:ss) """
Get-Date -Format (Get-culture).DateTimeFormat.UniversalSortableDateTimePattern
""
"Bases: pop/- us [math]::round(bases 1..4) = somme"
""
"[1 (($Xpop/2) - $Xenv) ] = " + [math]::round(($Xpop/2) - $Xenv)+" [klick's: env]"
"[2 (($Xpop/3) - ($Xind + $Xcom)) ] = " + [math]::round(($Xpop/3) - ($Xind + $Xcom))+" [klick's: ind+com]"
"[3 (($Xpop/4) - $Xsec) ] = " + [math]::round(($Xpop/4) - $Xsec)+" [klick's: sec]"
"[4 (($Xpop/5) - $Xtra) ] = " + [math]::round(($Xpop/5) - $Xtra)+" [klick's: tra]"
""
""" The ' "+$Xminiville+" ' Miniville is not equal ! """
"Pop's 50 % = "+[int]$Xpop

$Xtot = [int]$Xenv + [int]$Xind + [int]$Xcom + [int]$Xsec + [int]$Xtra

$Xplus_minus = [int]$Xtot - [int]$Xpop
"Somme Bases <> 50 % = ""env,(ind+(com)),sec,tra"" = " + $Xtot + " ""[klick's: " + "{0:### ###}" -f ($Xplus_minus) + " ]"""

clear-variable X* -scope global -F

""
"I hope this helps your situation. If not, I'd be happy to revisit"
""

Visit the table !
« Modifié: avril 09, 2023, 11:30:36 am par Arenas »

Hors ligne Arenas

  • Newbie
  • *
  • Messages: 17
  • Karma : 2
    • Voir le profil
    • http://arenas.pagesperso-orange.fr/GradientExample/france-countdown.html
Re : Synopsys: Usage des bases for Miniville
« Réponse #1 le: avril 19, 2023, 23:27:33 pm »
J'ai modifier le txt.

J'ai ajouter de la couleur
et les paramètre "if/else"


J'ai verras bien .....

Version ter
@

----------------------

cls

########################
#
# Synopsys:
#
# Creat
# 2023-02-10 00:33:07Z
# Modif
# 2023-02-25 10:25:47Z (last, ter)
#
# Copyright @renas alias (athome)
# France
#
# File Name :
# DownloadString-from-Mv-bases.ps1
#
# Us any Powershell version
# All Info are cumule
# Non restriction
#
# The convention is:
# 1 klick env for 2 pop
# 1 klick ind or *com for 3 pop
# 1 klick sec for 4 pop
# 1 klick tra for 5 pop
#
# * "com" is obsolete "Yстаревший, nicht verwenden, not tu use!
#
# Bases: pop/- us [math]::round(bases 1..4) = somme
#
# That's all to do. Great to hear from you.
#
########################

$Xt = [string] "#text"

# your Miniville city name

$Xminiville = "mv0" # also or: aldana-test, mv0, xenia, burschi, st-innsbruck, bangor, sandefri

$Xa = (Get-Host).UI.RawUI
$Xa.WindowTitle = "Sync Bases for $Xminiville"

$XmlUrl = "http://$Xminiville.miniville.fr/xml"
[xml]$Xml = (new-object System.Net.WebClient).DownloadString($XmlUrl)

$Xpop = $Xml.selectSingleNode('city/population').$Xt # $Xt = format txt
$Xcom = $Xml.selectSingleNode('city/bases/@com').$Xt
$Xenv = $Xml.selectSingleNode('city/bases/@env').$Xt
$Xind = $Xml.selectSingleNode('city/bases/@ind').$Xt
$Xsec = $Xml.selectSingleNode('city/bases/@sec').$Xt
$Xtra = $Xml.selectSingleNode('city/bases/@tra').$Xt
""
""" Last update Date/Time (yyyy-mm-dd hh:mm:ssz) """ # The Time is zulu
Get-Date -Format (Get-culture).DateTimeFormat.UniversalSortableDateTimePattern
""
"Bases: pop/- us [math]::round(bases 1..4) = somme"

""
# name f the City
Write-host "Ideal: 52 % for Pop and 48 % for Bases"
Write-host "The ' " -nonewline;
Write-host $Xminiville -ForegroundColor green -nonewline;
Write-host " ' MiniVille have :";
""
# the best is 52 %
$Xtot = [int]$Xpop
Write-host "Pop's <> 50 % = " -nonewline;
Write-host ("{0:## ### ###}" -f $Xtot) -ForegroundColor green;

$Xtot = [int]$Xenv + [int]$Xind + [int]$Xcom + [int]$Xsec + [int]$Xtra
$Xplus_minus =  [int]$Xtot - [int]$Xpop

if ($Xplus_minus -lt -0){
    Write-host "Somme bases <> 50 % = "" env,ind,com,sec,tra = +/- "" " -nonewline;
    Write-host ("{0:## ### ###}" -f $Xtot) -ForegroundColor red -nonewline;
    Write-host " [ klick: " -nonewline; $Xplus_minus_2 = "{0:## ### ###}" -f ($Xplus_minus)
    Write-host $Xplus_minus_2 -ForegroundColor green -nonewline;
    Write-host " ]""";
    }
else {
    Write-host "Somme bases <> 50 % = "" env,ind,com,sec,tra = +/- "" " -nonewline;
    Write-host  (" {0:## ### ###}" -f $Xtot) -ForegroundColor green -nonewline;
    Write-host " ""[ klick: missing pop! " -nonewline; $Xplus_minus_2 = "{0:## ### ###}" -f ($Xplus_minus)
    Write-host $Xplus_minus_2 -ForegroundColor red -nonewline;
    Write-host " ]""";
}


""
""
# If 500 pop, env is on
# 1 env
if ($Xenv -lt 0){Write-host """ Env is off """ -ForegroundColor yellow}
    else {Write-Host """ " -nonewline; Write-Host Env is on -ForegroundColor yellow -nonewline; " """}

if ($Xenv -gt 0){
    $Xround_env = [math]::round($Xenv - ($Xpop/2))
    if($Xround_env -gt 0){`
        Write-Host " [ 1 ($Xenv - ($Xpop/2)) ] = " -nonewline;
        Write-Host ("{0:## ### ###}" -f $Xround_env) -ForegroundColor green -nonewline;
        Write-Host " [Env]";
    }
    else {
        Write-Host " [ 1 ($Xenv - ($Xpop/2)) ] = " -nonewline;
        Write-Host ("{0:## ### ###}" -f  $Xround_env) -ForegroundColor Red
    }
}
# Si 50 pop, ind is off
# 2a ind
if ($Xind -lt 1){Write-host """ Ind is off """ -ForegroundColor yellow}
    else{Write-Host """ " -nonewline;
        Write-Host Ind is on -ForegroundColor yellow -nonewline; " """
    }

if ($Xind -gt 1){
    $Xround_ind = [math]::round($Xind - ($Xpop/3))
    if ($Xround_ind -gt 1){
        Write-Host " [ 2a ($Xind - ($Xpop/3)) ] = " -nonewline;
        Write-Host ("{0:## ### ###}" -f $Xround_ind) -ForegroundColor Green
    }
    else{
        Write-Host " [ 2a ($Xind - ($Xpop/3)) ] = " -nonewline;
        Write-Host ("{0:## ### ###}" -f $Xround_ind) -ForegroundColor Red
    }
}
# us switsh (if/else/elseif)
# Si -1 000 pop, com is off
# 2b com is obsolete, Yстаревший, nicht verwenden, not tu use!
if ($Xcom -lt 1000){Write-host """ Com is off """ -ForegroundColor yellow}
    else{Write-Host """ " -nonewline;
        Write-Host Com is on -ForegroundColor yellow -nonewline; " """
    }
if ($Xcom -gt 0){
    $Xround_com = [math]::round($Xcom/3)
    if ($Xround_com -gt 0){
        Write-Host " [ 2b ($Xcom/3) ] = " -nonewline;
        if ($Xround_com -eq 0){$Xround_com = "0"
            Write-Host ("{0:## ### ###}" -f $Xround_com) -ForegroundColor Green}
        else{Write-Host ("{0:## ### ###}" -f $Xcom) -ForegroundColor Green}
    }
    else{
        Write-Host " [ 2b ($Xcom/3) ] = " -nonewline;
        if ($Xround_com -eq 0){$Xround_com = "0"
            Write-Host ("{0:## ### ###}" -f $Xround_com) -ForegroundColor Red}
        else{Write-Host ("{0:## ### ###}" -f $Xcom) -ForegroundColor Red}
    }
}
# Si 300 pop, sec is off
# 3 sec
if ($Xsec -lt 0){Write-host """ Sec is off """ -ForegroundColor yellow}
    else{Write-Host """ " -nonewline;
        Write-Host Sec is on -ForegroundColor yellow -nonewline; " """
    }

if ($Xsec -gt 0){
    $Xround_sec = [math]::round($Xsec - ($Xpop/4))
    if($Xround_sec -gt 0){
        Write-Host " [ 3 ($Xsec - ($Xpop/4)) ] = " -nonewline;
        Write-Host ("{0:## ### ###}" -f $Xround_sec) -ForegroundColor Green
    }
    else{
        Write-Host " [ 3 ($Xsec - ($Xpop/4)) ] = " -nonewline;
        Write-Host ("{0:## ### ###}" -f $Xround_sec) -ForegroundColor Red
    }
}
# Si 100 pop, tra is off
# 4 tra
if ($Xpop -lt 100){Write-host """ Tra is off """ -ForegroundColor yellow}
    else{Write-Host """ " -nonewline;
    Write-Host Tra is on -ForegroundColor yellow -nonewline; " """
    }

if ($Xpop -gt 100){
    $Xround_tra = [math]::round($Xtra - ($Xpop/5))
    if($Xround_tra -gt 100){
        Write-Host " [ 4 ($Xtra - ($Xpop/5)) ] = " -nonewline;
        Write-Host ("{0:## ### ###}" -f $Xround_tra) -ForegroundColor Green
    }
    else{
        Write-Host " [ 4 ($Xtra - ($Xpop/5)) ] = " -nonewline;
        Write-Host ("{0:## ### ###}" -f $Xround_tra) -ForegroundColor Red
    }
}

""
$Xobs = "I hope this helps your situation. If not, I'd be happy to revisite`n"
$Xobs += "------------------------------------------------------------------`n"
$Xobs
""
clear-variable X* -scope global -F
-------------------------------------

30 avril 2023 - 00:44:08z évolutive
« Modifié: avril 30, 2023, 23:04:00 pm par Arenas »