Esempio n. 1
0
def fun_trade(n):
    """Generate Trade Classifications for a given UWP n"""
    siz = cnv.ext_dec(n[1])
    atm = cnv.ext_dec(n[2])
    hyd = cnv.ext_dec(n[3])
    pop = cnv.ext_dec(n[4])
    gov = cnv.ext_dec(n[5])
    law = cnv.ext_dec(n[6])
    tc = ""
    #print("UWP: ", n, "\nSize: ", siz, "| Atmo: ", atm, "| Hydro: ", hyd, "| Pop: ", pop, "| Gov: ", gov, "| Law: ", law, "\n")
    #Ag - Atm 5-9, Hyd 4-8, Pop 5-7
    if atm in [5, 6, 7, 8, 9] and hyd in [4, 5, 6, 7, 8] and pop in [5, 6, 7]:
        tc += "Ag "
    #As - Siz 0, Atm 0, Hyd 0
    if siz == 0 and atm == 0 and hyd == 0:
        tc += "As "
    #Ba - Pop 0, Gov 0, Law 0
    if pop == 0 and gov == 0 and law == 0:
        tc += "Ba "
    #De - Atm 2-9, Hydro 0
    if atm in [2, 3, 4, 5, 6, 7, 8, 9] and hyd == 0:
        tc += "De "
    #Fl - Atm 10-12, Hydro 1-10
    if atm in [10, 11, 12] and hyd in [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]:
        tc += "Fl "
    #Hi - Pop 9-15
    if pop in [9, 10, 11, 12, 13, 14, 15]:
        tc += "Hi "
    #Ic - Atm 0,1, Hydro 1-10
    if atm in [0, 1] and hyd in [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]:
        tc += "Ic "
    #In - Atm 0-4,7,9,10-12, Pop: 9-15
    if atm in [0, 1, 2, 3, 4, 7, 9, 10, 11, 12
               ] and pop in [9, 10, 11, 12, 13, 14, 15]:
        tc += "In "
    #Lo - Pop 1-3
    if pop in [1, 2, 3]:
        tc += "Lo "
    #Na - Atm 0-3, Hydo 0-3, Pop: 6-15
    if atm in [0, 1, 2, 3] and hyd in [0, 1, 2, 3] and pop in [
            6, 7, 8, 9, 10, 11, 12, 13, 14, 15
    ]:
        tc += "Na "
    #Ni - Pop 4-6
    if pop in [4, 5, 6]:
        tc += "Ni "
    #Po - Atm 2-5, Hydro 0-3
    if atm in [2, 3, 4, 5] and hyd in [0, 1]:
        tc += "Po "
    #Ri - Atm 6,8, Pop 6-8
    if atm in [6, 8] and pop in [
            6,
            7,
            8,
    ]:
        tc += "Ri "
    #Va - Atm 0
    if atm == 0:
        tc += "Va "
    return tc.strip()
Esempio n. 2
0
def spec_price(n, t):
    """
    Generate base cost of speculative cargo for a given set of trade codes n, with tech level t.
    """
    cost = 3000
    cost += cnv.ext_dec(t) * 100

    for i in range(len(n)):
        if n[i] == 'Ag':
            cost -= 1000
        if n[i] == 'As':
            cost -= 1000
        if n[i] == 'Ba':
            cost += 1000
        if n[i] == 'De':
            cost += 1000
        if n[i] == 'Fl':
            cost += 1000
        if n[i] == 'Hi':
            cost -= 1000
        if n[i] == 'Ic':
            cost += 0
        if n[i] == 'In':
            cost -= 1000
        if n[i] == 'Lo':
            cost += 1000
        if n[i] == 'Na':
            cost += 0
        if n[i] == 'Ni':
            cost += 1000
        if n[i] == 'Po':
            cost -= 1000
        if n[i] == 'Ri':
            cost += 1000
        if n[i] == 'Va':
            cost += 1000

    return cost
Esempio n. 3
0
def fun_pbg(uwp):
    """
  Generate the Population Digit, Gas Giants & Asteroid Belts
  
  Arguments, uwp the UWP to process to get population digit.
  """

    p = cnv.ext_dec(str(uwp[4]))
    pop = 0
    if p == 0:
        pop = 0
    else:
        pop = dd.dice(2) - 3
        if pop < 1:
            pop = 1
    belt = dd.die_roll() - 3
    if belt < 0:
        belt = 0
    gas = round(dd.dice(2) / 2) - 2
    if gas < 0:
        gas = 0
    pbg = str(pop) + str(belt) + str(gas)
    return pbg
Esempio n. 4
0
def fun_ext(uwp, pbg, bases, trade):
    """
  Generates the Extended Profile for a planet {Ix}(Ex)[Cx].
  
  Takes as variables, UWP, Pop-belt-gas giant, bases list, Trade Codes
  
  Importance (Ix)
  Economic (Ex) - (RLI+E)
  R - Resources, L - Labour, I - Infrastruture, E - Efficiency
  Cultural (Cx) - [HASS]
  H - Heterogeneity, A - Acceptance, S - Strangeness, S - Symbols
  """
    #Importance
    i = 0
    sport = str(uwp[0])
    bases = str(bases)
    tech = cnv.ext_dec(str(uwp[-1]))
    pop = cnv.ext_dec(str(uwp[4]))
    sprt_fac = {"A": 1, "B": 1, "C": 0, "D": -1, "E": -1, "X": -1}
    i += sprt_fac[sport]
    if (tech > 15):
        i += 1
    elif (tech > 9):
        i += 1
    elif (tech < 9):
        i -= 1
    if (pop < 7):
        i -= 1
    if (bases == "NS"):
        i += 1
    if "Ag" in trade:
        i += 1
    if "Hi" in trade:
        i += 1
    if "In" in trade:
        i += 1
    if "Ri" in trade:
        i += 1
    if i > 5:
        i = 5
    if i < -3:
        i = -3
    ix = "{"
    if i > -1:
        ix += "+" + str(i) + "}"
    else:
        ix += str(i) + "}"
    ##Economic
    belt = int(str(pbg[1]))
    gas = int(str(pbg[2]))
    ex = ""
    r = dd.dice(2)
    if (tech > 7):
        r = r + belt + gas
    l = pop - 1
    if (l < 0):
        l = 0
    if (pop == 0):
        inf = 0
    elif (0 < pop < 4):
        inf = i
    elif (3 < pop < 7):
        inf = i + dd.die_roll()
    elif (pop > 6):
        inf = i + dd.dice(2)
    if inf < 0:
        inf = 0
    e = dd.flux()
    ex = "(" + str(cnv.ext_hex(r)) + str(cnv.ext_hex(l)) + str(
        cnv.ext_hex(inf))
    if (e >= 0):
        ex = ex + "+" + str(e) + ")"
    else:
        ex = ex + str(e) + ")"
    ##Cultural
    h = pop + dd.flux()
    a = pop + i
    s = dd.flux() + 5
    sy = dd.flux() + tech
    if (pop == 0):
        h = a = s = sy = 0
    if (h < 1):
        h = 1
    if (a < 1):
        a = 1
    if (s < 1):
        s = 1
    if (sy < 1):
        sy = 1
    cx = "[" + str(cnv.ext_hex(h)) + str(cnv.ext_hex(a)) + str(
        cnv.ext_hex(s)) + str(cnv.ext_hex(sy)) + "]"
    return (ix + ex + cx)
Esempio n. 5
0
def sell_price(n, d, b=0, t=0):
    """
    takes arguments of a Cargo Code (n) in the format: E - Hi In Na Va Cr3,400, Brokers Skill default is 0, no broker (b), Any Trader Roll default to 0, no trader (t) and Destination UWP (d) in the format A430311-B, it returns the sell price of the goods, taking brokering into account.
    """
    price = 5000
    if b > 0:
        if b > 8:
            b = 8
        b = int(round(b / 2))
    if t > 0:
        if t > 6:
            t = 6
    dtech = cnv.ext_dec(d[8])
    dtrade = sy.fun_trade(d).split()
    stech = cnv.ext_dec(n[0])
    strade = n[3:n.find("Cr")].split()
    #print("DestTech: {}; DestTrade: {}; SourceTech: {}; SourceTrade: {}; Broker: {}".format(dtech,dtrade,stech,strade,b))
    ptech = (stech - dtech) * 0.1
    pr = 0
    for i in range(len(strade)):
        if strade[i] == 'Ag':
            for x in range(len(dtrade)):
                if dtrade[x] == 'Ag':
                    pr += 1000
                if dtrade[x] == 'As':
                    pr += 1000
                if dtrade[x] == 'De':
                    pr += 1000
                if dtrade[x] == 'Hi':
                    pr += 1000
                if dtrade[x] == 'In':
                    pr += 1000
                if dtrade[x] == 'Ri':
                    pr += 1000
                if dtrade[x] == 'Va':
                    pr += 1000
        if strade[i] == 'As':
            for x in range(len(dtrade)):
                if dtrade[x] == 'As':
                    pr += 1000
                if dtrade[x] == 'In':
                    pr += 1000
                if dtrade[x] == 'Ri':
                    pr += 1000
                if dtrade[x] == 'Va':
                    pr += 1000
        if strade[i] == 'Ba':
            for x in range(len(dtrade)):
                if dtrade[x] == 'In':
                    pr += 1000
        if strade[i] == 'De':
            for x in range(len(dtrade)):
                if dtrade[x] == 'De':
                    pr += 1000
        if strade[i] == 'Fl':
            for x in range(len(dtrade)):
                if dtrade[x] == 'Fl':
                    pr += 1000
                if dtrade[x] == 'In':
                    pr += 1000
        if strade[i] == 'Hi':
            for x in range(len(dtrade)):
                if dtrade[x] == 'Hi':
                    pr += 1000
        if strade[i] == 'Ic':
            pr += 0
        if strade[i] == 'In':
            for x in range(len(dtrade)):
                if dtrade[x] == 'Ag':
                    pr += 1000
                if dtrade[x] == 'As':
                    pr += 1000
                if dtrade[x] == 'De':
                    pr += 1000
                if dtrade[x] == 'Fl':
                    pr += 1000
                if dtrade[x] == 'Hi':
                    pr += 1000
                if dtrade[x] == 'In':
                    pr += 1000
                if dtrade[x] == 'Ri':
                    pr += 1000
                if dtrade[x] == 'Va':
                    pr += 1000
        if strade[i] == 'Lo':
            pr += 0
        if strade[i] == 'Na':
            for x in range(len(dtrade)):
                if dtrade[x] == 'As':
                    pr += 1000
                if dtrade[x] == 'De':
                    pr += 1000
                if dtrade[x] == 'Va':
                    pr += 1000
        if strade[i] == 'Ni':
            pr += 0
        if strade[i] == 'Po':
            for x in range(len(dtrade)):
                if dtrade[x] == 'Ag':
                    pr -= 1000
                if dtrade[x] == 'Hi':
                    pr -= 1000
                if dtrade[x] == 'In':
                    pr -= 1000
                if dtrade[x] == 'Ri':
                    pr -= 1000
        if strade[i] == 'Ri':
            for x in range(len(dtrade)):
                if dtrade[x] == 'Ag':
                    pr += 1000
                if dtrade[x] == 'De':
                    pr += 1000
                if dtrade[x] == 'Hi':
                    pr += 1000
                if dtrade[x] == 'In':
                    pr += 1000
                if dtrade[x] == 'Ri':
                    pr += 1000
        if strade[i] == 'Va':
            for x in range(len(dtrade)):
                if dtrade[x] == 'As':
                    pr += 1000
                if dtrade[x] == 'In':
                    pr += 1000
                if dtrade[x] == 'Va':
                    pr += 1000
    br = {
        -5: 0.4,
        -4: 0.5,
        -3: 0.7,
        -2: 0.8,
        -1: 0.9,
        0: 1.0,
        1: 1.1,
        2: 1.2,
        3: 1.3,
        4: 1.5,
        5: 1.7,
        6: 2.0,
        7: 3.0,
        8: 4.0
    }
    if b > 0:
        if t > 0:
            broker = t - dd.die_roll() + b
            if broker > 8:
                broker = 8
            if broker < -5:
                broker = -5
            pbrk = br[broker]
        else:
            broker = dd.flux() + b
            if broker > 8:
                broker = 8
            if broker < -5:
                broker = -5
            pbrk = br[broker]
    else:
        broker = dd.flux()
        if broker > 8:
            broker = 8
        if broker < -5:
            broker = -5
        pbrk = br[broker]
    price = price + pr
    tpr = int(price * ptech)
    #print('price: {}; tech effect: {}; {}; broker: {}'.format(price,ptech,tpr, pbrk))
    price += tpr
    print('Base Price: {}\n'.format(price))
    if price < 0:
        price = 0
    price = int(price * pbrk)
    return price
Esempio n. 6
0
def trade_gds(n,
              skill={
                  'Steward': 0,
                  'Admin': 0,
                  'Streetwise': 0,
                  'Liaison': 0
              },
              days=7):
    """
    Generate trade goods for a given UWP. Using skills, skill, where skill is {Steward, Admin, Streetwise, Liaison} defaults = 0, for a given number of days default = 7.
    """

    pop = cnv.ext_dec(n[4])
    tech = n[8]
    trade = sy.fun_trade(n)
    trades = trade.split()

    admin = skill['Admin']
    street = skill['Streetwise']
    steward = skill['Steward']
    liaise = skill['Liaison']

    high = dd.flux() + pop + steward
    mid = dd.flux() + pop + admin
    low = dd.flux() + pop + street
    if high < 0:
        high = 0
    if mid < 0:
        mid = 0
    if low < 0:
        low = 0

    i = 0
    freight = ['None'] * days
    cargo = ['None'] * days
    frttot = 0
    while i < days:
        amount = dd.flux() + pop
        if amount < 0:
            amount = 0
        frttot += amount
        frtprc = amount * 1000
        freight[i] = '{}dt of {} at Cr{:,}'.format(amount, trade_goods(trades),
                                                   frtprc)
        cargo[i] = '100dt of ' + trade_goods(trades)
        i += 1
    frt = "\n|=> ".join(freight)
    cgo = "\n|=> ".join(cargo)
    trd = "During the last {} days you find:\n".format(days)
    trd = trd + "* High Passengers: {} at Cr10,000 +/- Cr1,000 depending on demand\n".format(
        high)
    trd = trd + "* Middle Passengers: {} at Cr8,000 +/- Cr1,000 depending on demand\n".format(
        mid)
    trd = trd + "* Low Passengers: {} at Cr1,000 +/- Cr100 depending on demand\n---\n".format(
        low)
    trd = trd + "* Freight totalling {}dt in lots:\n|=> {}\n".format(
        frttot, frt)
    trd = trd + "* Spec Cargo available:\n|=> {}\n".format(cgo)
    tc = " ".join(map(str, trades))
    cost = spec_price(trades, tech)
    crgo = "{} - {} Cr{:,}".format(tech, tc, cost)
    trd = trd + "|===> Spec Cargo Cost: {} per dt.".format(crgo)

    return trd