from os import listdir
from os.path import join

from transistors.GameChild import *
from Slide import *

class Slides(GameChild):

    def __init__(self, parent):
        GameChild.__init__(self, parent)
        self.load()
        self.current = 0

    def load(self):
        slides = []
        directory = self.get_resource("introduction-images-path")
        for path in sorted(listdir(directory)):
            slides.append(Slide(self, join(directory, path)))
        self.slides = slides

    def reset(self):
        self.current = 0

    def advance(self):
        looped = False
        current = self.current + 1
        if current >= len(self.slides):
            current = 0
            looped = True
        self.current = current
        return not looped

    def draw(self):
        self.slides[self.current].draw()
from pygame import image
from pygame.transform import smoothscale

from transistors.GameChild import *

class Slide(GameChild):

    def __init__(self, parent, path):
        GameChild.__init__(self, parent)
        self.path = path
        self.destination = self.get_screen()
        self.load()

    def load(self):
        size = self.destination.get_size()
        self.slide = smoothscale(image.load(self.path), size).convert()

    def draw(self):
        self.destination.blit(self.slide, (0, 0))
class Parameters:

    ints = ["time-limit", "display-frame-duration", "display-wait-duration",
            "terrain-size", "orb-size", "orb-padding", "manna-size",
            "cells-type-count", "audio-bg-channel", "terrain-border"]

    floats = ["territory-initial-coverage"]

    tuples = ["display-dimensions"]

    paths = ["introduction-images-path", "capture-path"]

    str_lists = ["territory-colors", "keys-reset", "keys-capture-screen",
                 "keys-quit"]

    bools = []
import re
import os
from os.path import isfile, join

import pygame

from Parameters import *

class Configuration(dict):

    assignment_operator = "="
    comments_operator = "#"
    field_separator = ","
    keys_prefix = "keys_"
    true_values = ["yes", "y", "true", "t", "1"]
    
    def __init__(self):
        self.set_file_path()
        self.parse()

    def set_file_path(self):
        path = "config"
        if not isfile(path):
            path = join("/usr/local/share/transistors/", path)
        self.file_path = path            
    
    def parse(self):
        for line in file(self.file_path):
            line = line.strip()
            if len(line) > 0 and line[0] != self.comments_operator:
                (lval, rval) = map(
                    str.strip, line.split(self.assignment_operator))
                if lval in Parameters.ints:
                    rval = int(rval)
                if lval in Parameters.floats:
                    rval = float(rval)
                if lval in Parameters.bools:
                    rval = True if self.is_true_value(rval) else False
                if lval in Parameters.paths:
                    rval = os.path.join(*rval.split(os.sep))
                if lval in Parameters.tuples:
                    rval = eval(rval)
                if lval in Parameters.str_lists:
                    rval = map(str.strip, rval.split(self.field_separator))
                    if self.is_key_assignment(lval):
                        rval = map(lambda key: getattr(pygame, key), rval)
                self[lval] = rval

    def is_true_value(self, rval):
        return rval.lower() in self.true_values

    def is_key_assignment(self, lval):
        pattern = "^" + self.keys_prefix + "*"
        return re.match(pattern, lval) is not None
from transistors.GameChild import *
from transistors.EventDelegate import *
from terrain.Terrain import *

class World(GameChild):

    def __init__(self, parent):
        GameChild.__init__(self, parent)
        self.deactivate()
        self.subscribe_to_events()
        self.add_terrain()

    def subscribe_to_events(self):
        self.subscribe_to(EventDelegate.state_change_event,
                          self.respond_to_state_change)

    def respond_to_state_change(self, evt):
        if evt.state == "introduction-finished":
            self.activate()

    def activate(self):
        self.active = True
        self.set_music()

    def set_music(self):
        self.get_audio().play_bgm(self.get_resource("world-music-path"))

    def deactivate(self):
        self.active = False

    def add_terrain(self):
        width, height = self.get_screen().get_size()
        terrain_width = self.get_configuration()["terrain-size"]
        terrain = []
        for ii in range(width / terrain_width + 1):
            for jj in range(height / terrain_width + 1):
                terrain.append(Terrain(self, (ii, jj)))
        self.terrain = terrain        

    def update(self):
        if self.active:
            for terrain in self.terrain:
                terrain.update()
from pygame import Surface, Rect, Color

from transistors.GameChild import *

class Terrain(GameChild, Surface):

    def __init__(self, parent, coordinates):
        GameChild.__init__(self, parent)
        self.coordinates = coordinates
        self.init_surface()
        self.set_rect()
        self.set_background()
        self.set_clip()

    def init_surface(self):
        width = self.get_configuration()["terrain-size"]
        Surface.__init__(self, (width, width))

    def set_rect(self):
        rect = self.get_rect()
        ii, jj = self.coordinates
        offset = self.get_width() / 2
        rect.topleft = ii * rect.w - offset, jj * rect.w - offset
        self.rect = rect

    def set_background(self):
        background = Surface(self.get_size())
        background.fill(Color(self.get_configuration()["terrain-border-color"]))
        self.blit(background, (0, 0))
        self.background = background

    def set_clip(self):
        width = self.get_width() - self.get_configuration()["terrain-border"]
        Surface.set_clip(self, Rect(0, 0, width, width))

    def update(self):
        self.clear()
        self.draw()

    def clear(self):
        self.blit(self.background, (0, 0))

    def draw(self):
        self.fill(Color("black"))
        self.get_screen().blit(self, self.rect)
216.73.216.215
216.73.216.215
216.73.216.215
 
July 18, 2022


A new era ‼

Our infrastructure has recently upgraded ‼

Nugget Communications Bureau 👍

You've never emailed like this before ‼

Roundcube

Webmail software for reading and sending email from @nugget.fun and @shampoo.ooo addresses.

Mailman3

Email discussion lists, modernized with likes and emojis. It can be used for announcements and newsletters in addition to discussions. See lists for Picture Processing or Scrapeboard. Nowadays, people use Discord, but you really don't have to!

FreshRSS

With this hidden in plain sight, old technology, even regular people like you and me can start our own newspaper or social media feed.

Nugget Streaming Media 👍

The content you crave ‼

HLS

A live streaming, video format based on M3U playlists that can be played with HTML5.

RTMP

A plugin for Nginx can receive streaming video from ffmpeg or OBS and forward it as an RTMP stream to sites like Youtube and Twitch or directly to VLC.


Professional ‼

Nugget Productivity Suite 👍

Unleash your potential ‼

Kanboard

Virtual index cards you can use to gamify your daily grind.

Gitea

Grab whatever game code you want, share your edits, and report bugs.

Nugget Security 👍

The real Turing test ‼

Fail2ban

Banning is even more fun when it's automated.

Spamassassin

The documentation explains, "an email which mentions rolex watches, Viagra, porn, and debt all in one" will probably be considered spam.

GoAccess

Display HTTP requests in real time, so you can watch bots try to break into WordPress.

Nugget Entertainment Software 👍

The best in gaming entertainment ‼

Emoticon vs. Rainbow

With everything upgraded to the bleeding edge, this HTML4 game is running better than ever.


Zoom ‼

The game engine I've been working on, SPACE BOX, is now able to export to web, so I'm planning on turning nugget.fun into a games portal by releasing my games on it and adding an accounts system. The upgraded server and software will make it easier to create and maintain. I'm also thinking of using advertising and subscriptions to support the portal, so some of these services, like webmail or the RSS reader, may be offered to accounts that upgrade to a paid subscription.