コード例 #1
0
def move_palette_action(request, action_slug, level_slug, new_column, new_row):
    """Moves the Designer Grid Action from the palette to the new column and row."""
    _ = request

    action = smartgrid_mgr.get_designer_action(action_slug)
    level = DesignerLevel.objects.get(slug=level_slug)
    grid = DesignerGrid()
    grid.level = level
    grid.column = new_column
    grid.row = new_row
    grid.action = action
    grid.save()

    #  Return the pk for the moved action.
    return HttpResponse(json.dumps({
            "pk": action.pk,
            }), mimetype="application/json")
コード例 #2
0
def instantiate_action(request, action_slug, level_slug, column, row):
    """Instantiated the Smart Grid Game Action from the Library Action with the
    given level, column, and row."""
    _ = request
    grid_action = smartgrid_mgr.instantiate_designer_from_library(action_slug)
    level = DesignerLevel.objects.get(slug=level_slug)
    grid = DesignerGrid()
    grid.level = level
    grid.column = column
    grid.row = row
    grid.action = grid_action
    grid.save()

    #  Return the new pk for the instantiated action.
    return HttpResponse(json.dumps({
            "pk": grid_action.pk,
            }), mimetype="application/json")
コード例 #3
0
def move_palette_action(request, action_slug, level_slug, new_column, new_row,
                        draft_slug):
    """Moves the Designer Grid Action from the palette to the new column and row."""
    _ = request
    draft = smartgrid_mgr.get_designer_draft(draft_slug)
    action = smartgrid_mgr.get_designer_action(draft, action_slug)
    level = smartgrid_mgr.get_designer_level(draft, level_slug)
    grid = DesignerGrid()
    grid.level = level
    grid.column = new_column
    grid.row = new_row
    grid.action = action
    grid.draft = draft
    grid.save()

    #  Return the pk for the moved action.
    return HttpResponse(json.dumps({
        "pk": action.pk,
    }),
                        mimetype="application/json")
コード例 #4
0
ファイル: smartgrid_mgr.py プロジェクト: csdl/makahiki
def copy_smartgrid_to_designer(draft):
    """Copies the current Smart Grid Game to the given designer draft."""
    # Clear out the Designer
    clear_designer(draft)
    # Copy the levels
    for lvl in Level.objects.all():
        try:
            des_lvl = get_object_or_404(DesignerLevel, draft=draft, slug=lvl.slug)
        except Http404:
            des_lvl = DesignerLevel()
            des_lvl.draft = draft
        _copy_fields(lvl, des_lvl)
    # Copy the ColumnNames
    for col in ColumnName.objects.all():
        try:
            des_col = get_object_or_404(DesignerColumnName, draft=draft, slug=col.slug)
        except Http404:
            des_col = DesignerColumnName()
            des_col.draft = draft
        _copy_fields(col, des_col)
    # Copy the location information
    for grid in ColumnGrid.objects.all():
        col = DesignerColumnGrid()
        col.level = get_designer_level(draft, grid.level.slug)
        col.column = grid.column
        col.name = get_designer_column_name(draft, grid.name.slug)
        col.draft = draft
        col.save()
    # Copy the Actions
    for action in Action.objects.all():
        instantiate_designer_action_from_smartgrid(draft, action.slug)
    # Copy the location information
    for grid in Grid.objects.all():
        loc = DesignerGrid()
        loc.level = get_designer_level(draft, grid.level.slug)
        loc.column = grid.column
        loc.row = grid.row
        loc.action = get_designer_action(draft, grid.action.slug)
        loc.draft = draft
        loc.save()
コード例 #5
0
def copy_smartgrid_to_designer(draft):
    """Copies the current Smart Grid Game to the given designer draft."""
    # Clear out the Designer
    clear_designer(draft)
    # Copy the levels
    for lvl in Level.objects.all():
        try:
            des_lvl = get_object_or_404(DesignerLevel, draft=draft, slug=lvl.slug)
        except Http404:
            des_lvl = DesignerLevel()
            des_lvl.draft = draft
        _copy_fields(lvl, des_lvl)
    # Copy the ColumnNames
    for col in ColumnName.objects.all():
        try:
            des_col = get_object_or_404(DesignerColumnName, draft=draft, slug=col.slug)
        except Http404:
            des_col = DesignerColumnName()
            des_col.draft = draft
        _copy_fields(col, des_col)
    # Copy the location information
    for grid in ColumnGrid.objects.all():
        col = DesignerColumnGrid()
        col.level = get_designer_level(draft, grid.level.slug)
        col.column = grid.column
        col.name = get_designer_column_name(draft, grid.name.slug)
        col.draft = draft
        col.save()
    # Copy the Actions
    for action in Action.objects.all():
        instantiate_designer_action_from_smartgrid(draft, action.slug)
    # Copy the location information
    for grid in Grid.objects.all():
        loc = DesignerGrid()
        loc.level = get_designer_level(draft, grid.level.slug)
        loc.column = grid.column
        loc.row = grid.row
        loc.action = get_designer_action(draft, grid.action.slug)
        loc.draft = draft
        loc.save()
コード例 #6
0
def instantiate_action(request, action_slug, level_slug, column, row,
                       draft_slug):
    """Instantiated the Smart Grid Game Action from the Library Action with the
    given level, column, and row."""
    _ = request
    draft = smartgrid_mgr.get_designer_draft(draft_slug)
    grid_action = smartgrid_mgr.instantiate_designer_action_from_library(
        draft, action_slug)
    level = smartgrid_mgr.get_designer_level(draft, level_slug)
    grid = DesignerGrid()
    grid.level = level
    grid.column = column
    grid.row = row
    grid.action = grid_action
    grid.draft = draft
    grid.save()

    #  Return the new pk for the instantiated action.
    return HttpResponse(json.dumps({
        "pk": grid_action.pk,
    }),
                        mimetype="application/json")